Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help vehicle brake sound

Mat Sinister
Registered User
Join date: 7 Feb 2009
Posts: 14
03-02-2009 06:41
When I press back and speed is over 5 the car play the brake sound but if I keep back pressed and the speed is zero the bike always play the brake sound instead of the idlesound :(




control(key id, integer levels, integer edges)
{





if((edges & levels & CONTROL_BACK))
{
AddSound = 1;
}




if(AddSound)
{

if ((levels & CONTROL_BACK) && (speed>5))

{

Sound=BrakeSound;

}


else Sound=IdleSound;

}



timer()
{
vel = llGetVel();
speed = llVecMag(vel);

if(AddSound)
{
llStopSound();
NewSound = 0;
llLoopSound(Sound, 1.0);
}
}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
03-02-2009 09:22
speed = llVecMag(vel); is always >=0 so it is positive when you drive backwards
if your forward direction is the X axis try something like this:
CODE
control(key id, integer levels, integer edges)
{
if((edges & levels & CONTROL_BACK))
{
AddSound = 1;
}

if(AddSound)
{
if ((levels & CONTROL_BACK) && (speed>5))
{
Sound=BrakeSound;
}
else Sound=IdleSound;
}
}

timer()
{
vel = llGetVel();
speed = llVecMag(vel);
float DD = llRot2Fwd(llGetRot())*vel; // (dot product)
if ( DD<0.0 ) speed = -speed;

if(AddSound)
{
llStopSound();
NewSound = 0;
llLoopSound(Sound, 1.0);
}
}
_____________________
From Studio Dora
Mat Sinister
Registered User
Join date: 7 Feb 2009
Posts: 14
03-02-2009 12:25
Tried but look like it only check the speed 1 time only, if I keep it pressed while the speed is below 5 the sound do not change.

The only way to change the sound is to release and press again CONTROL_BACK when speed is below 5.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
03-02-2009 12:35
From: Mat Sinister
Tried but look like it only check the speed 1 time only, if I keep it pressed while the speed is below 5 the sound do not change.

The only way to change the sound is to release and press again CONTROL_BACK when speed is below 5.
That's because you're checking for edges&CONTROL_BACK, so you're only changing the sound when you actually press the button.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Mat Sinister
Registered User
Join date: 7 Feb 2009
Posts: 14
03-02-2009 14:09
Thank you!

Lost a day for a missed edges :D