05-06-2006 17:37
This is driving me nuts. I pared down my zeppelin script, trying to isolate where I was getting this weird turning behavior, until I got to this point, and now I'm just baffled. To see my problem, trying stuffing the script below into a prim and sit on it. Press page up or page down. The prim pitches appropriately, stopping after a few seconds when its maximum pitch is reached, due to the verticle attractor. Let go and it rights itself. So far, so good. Press left or right, again, prim leans over to its maximum. It also tends to turn slightly, which it shouldn't because I have banking disabled, but hey, nobody's perfect. I can live with that (I want banking enabled in my actual build, I just disabled it for demonstration purposes here). Let up and the prim rights itself. Okie dokie.

Now, lean over to the left or right fully, then, while still leaning over, pitch up or down. WHOA! The prim zips around, turning a full 360 degrees before stopping once maximum pitch is achieved. Release the up or down, and the prim zips around 360 degrees in the opposite direction as it levels off.

Two questions:

(1) WTF?
(2) How do I work around this, so my vehicle doesn't spin around while I'm trying to both turn and ascend/descend at the same time? So far, the only solutions I've come up with are to either not pitch during ascent/descent (using lift instead), or not roll for turns (doing yaw-based turning instead), but both of these cause you to lose a nice visual effect. Ideas?

CODE

default
{
state_entry()
{
llSitTarget(<0.1, 0.0, 0.0>, ZERO_ROTATION);
llSetSitText("Board");

llSetCameraEyeOffset(<-10.0, 0.0, 1.0>);
llSetCameraAtOffset(<0.0, 0.0, 1.0>);

llSetVehicleType( VEHICLE_TYPE_AIRPLANE);
llRemoveVehicleFlags( VEHICLE_FLAG_LIMIT_ROLL_ONLY);

llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1.0);

llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0.0, 0.0, 0.0>);
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 4.0);
llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 1.0);
llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <5.0, 5.0, 5.0>);

llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0.0, 0.0, 0.0>);
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 1.0);
llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1.0, 1.0, 1.0>);

llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1.0);
llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 5.0);

llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 0.0);
llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 1.0);
llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 1000.0);

llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.1);
llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 4.0);

llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 1.0);
llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 1.0);
}

changed(integer change)
{
if ( change & CHANGED_LINK )
{
key who = llAvatarOnSitTarget();
if ( who != NULL_KEY )
{
llRequestPermissions(who, PERMISSION_TAKE_CONTROLS);
}
else
{
llSetStatus(STATUS_PHYSICS, FALSE);
llReleaseControls();
}
}
}

run_time_permissions(integer perm)
{
if ( perm & PERMISSION_TAKE_CONTROLS )
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT
| CONTROL_UP | CONTROL_DOWN | CONTROL_LEFT | CONTROL_RIGHT, 1, 0);
llSetStatus(STATUS_PHYSICS, TRUE);
}
}

control(key id, integer level, integer edge)
{
float motor = 0.0;
float lift = 0.0;

float roll = 0.0;
float pitch = 0.0;
float yaw = 0.0;

if ( level & CONTROL_FWD )
{
motor += 20.0;
}
if ( level & CONTROL_BACK )
{
motor -= 10.0;
}
if ( (level & CONTROL_ROT_LEFT) || (level & CONTROL_LEFT) )
{
roll -= PI * 4;
}
if ( (level & CONTROL_ROT_RIGHT) || (level & CONTROL_RIGHT) )
{
roll += PI * 4;
}

if ( level & CONTROL_UP )
{
pitch -= PI * 4;
}
if ( level & CONTROL_DOWN )
{
pitch += PI * 4;
}

llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <motor, 0.0, lift>);
llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <roll, pitch, yaw>);
}
}