Jump to content
Sign in to follow this  
ChaosRaine

animating vehicle scripts

Recommended Posts

I am writing a vehicle script and I can get most of it to work. It takes control steers nicely and all that good stuff. I can get it to play an animation when I press forward, back, left and right, however after moving I can't get it to play an idle animation when no control buttons are being pressed. Does anybody know his to add that? I can post my script here tomorrow if you need to see it.

Share this post


Link to post
Share on other sites

I often use the control on 'Page Down' Key to set the motors to zero

Something like this:

if(level & CONTROL_DOWN){    gLinearMotor = ZERO_VECTOR;    llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);    angular_motor = ZERO_VECTOR;    llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);}

I hope this will help you

:smileysurprised::):smileyvery-happy:

Share this post


Link to post
Share on other sites

I'm not having trouble with the vehicles motion. I want animations to play I'm moving and a different when I'm stopped. I tried to put in timers that checked for control buttons being pressed but all I could get was a check if the button was pressed we've the last timed event, so if I hold the button down threw two timed events it would pay the idle animation again instead of the survival one.

Share this post


Link to post
Share on other sites

I misunderstood.

Maybe llGetVel() can help you, it provides the velocity of your vehicle

The magnitude of the velocity equals the speed of your vehicle, so

if ( llVecMag( llGetVel()) > 0.0 ) the vehicle is moving
else the vehicle is not moving

Hope that helps

:smileysurprised::):smileyvery-happy:

Share this post


Link to post
Share on other sites

If you mean you want to detect, in the control event, if nothing is being pressed, try something like this, based on the Wiki example,

default{    state_entry()    {        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);    }    run_time_permissions(integer perm)    {        if(PERMISSION_TAKE_CONTROLS & perm)        {            llTakeControls(                            CONTROL_FWD |                            CONTROL_BACK |                            CONTROL_LEFT |                            CONTROL_RIGHT |                            CONTROL_ROT_LEFT |                            CONTROL_ROT_RIGHT |                            CONTROL_UP |                            CONTROL_DOWN |                             CONTROL_LBUTTON |                            CONTROL_ML_LBUTTON |                            0, TRUE, FALSE);                            // | 0 is for edit convenience,                            // it does not change the mask.        }    }            control(key id, integer level, integer edge)    {        integer start = level & edge;        integer end = ~level & edge;        integer held = level & ~edge;        integer untouched = ~(level | edge);        //llOwnerSay(llList2CSV([level, edge, start, end, held, untouched]));                integer playAnim = FALSE;        llSetTimerEvent(0.0);                if(end){          playAnim=TRUE;                   }                        if(untouched){                  if(playAnim){             playAnim=FALSE;             llSetTimerEvent(0.5);            return;            }        }    }        timer(){      llSetTimerEvent(0.0);      llOwnerSay("should play idle animation here");       }}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...