Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llApplyImpulse() for a choppers "rudder"

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
03-13-2008 14:46
ive been playing around with this idea for a week or so now and i thought i had it right but the chopper dosent agree with me lol. the rudder is based on speed if you under 5 you will have a rudder if over 5 it will do the regular turning that ive scripted in. here are the parts im having trouble with. sometimes the impulses will work and other times i slow down and stop and the impulses wont turn the chopper

CODE

float myMass

//state_entry()

myMass = llGetMass()

//control

if ((level & CONTROL_ROT_RIGHT) | (level & CONTROL_RIGHT))
{
if(speed > 2.5)
{
turning = TRUE;
adecayoff = TRUE;
turn = .7;
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <turn,0,0>);
}
else if(speed < 2.5)
{
turning = FALSE;
adecayoff = TRUE;
llApplyRotationalImpulse(<0,0,-.7> * myMass, TRUE);
}
}

if ((level & CONTROL_ROT_LEFT) | (level & CONTROL_LEFT))
{
if(speed > 2)
{
turning = TRUE;
adecayoff = TRUE;
turn = -.7;
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <turn,0,0>);
}
else if(speed < 2)
{
turning = FALSE;
adecayoff = TRUE;
llApplyRotationalImpulse(<0,0,.7> * myMass, TRUE);
}
}

//turning()

if(turning)
{
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <turn,0,0>);
turn = 0;
turning = FALSE;
}

//timer()

integer speed = (integer)(llVecMag(llGetVel()) * 1.94384449 + 0.5);
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
03-13-2008 15:02
it seams to work now but ......

when i try to turn left 60% of the time it refuces to turn atall till i turn right