|
Cobalt Neutra
As seen on radio
Join date: 13 Sep 2004
Posts: 48
|
05-24-2006 21:27
I'm working on a car, which is using the arrow keys to accelerate, brake and turn.
I'm trying to set it so that when "up arrow" is pused, to make the car accelerate, an "accelerating engine" sound plays - but as soon as the "up arrow" is released, the car goes back to an "engine idle" sound.
Here's what I have right now:
--------------------------------------
if(level & CONTROL_FWD)
{ cur_wheel_direction = "WHEEL_FORWARD"; llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power,0,0> ); reverse=1; llLoopSound("engine accelerate",1.0); } if(~level & CONTROL_FWD) { llMessageLinked(LINK_SET, 0, "Wheelstop", NULL_KEY); llLoopSound("engine idle",1); }
---------------------------------
My problem: sound is choppy, with loud blasts as it switches from one sound to the other. Further, pressing "down arrow" "left arrow" or "right arrow" keys, causes the idle sound to go into a stuttering loop, as it appears to be rapidly trying to restart from the beginning, over and over again.
Is there a better way to implement tis?
|
|
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
|
05-24-2006 22:55
Try this version? This way it only toggled the sound at those instants when the forward control is first pressed or first released, instead of continuously triggering things (since you're using 'level' I assume you're also using the name 'edge' for the other variable  ). if(edge & level & CONTROL_FWD) { cur_wheel_direction = "WHEEL_FORWARD"; llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIREC TION, <forward_power,0,0> ); reverse=1; llLoopSound("engine accelerate",1.0); } if(edge & ~level & CONTROL_FWD) { llMessageLinked(LINK_SET, 0, "Wheelstop", NULL_KEY); llLoopSound("engine idle",1); }
_____________________
- Making everyone's day just a little more surreal -
Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
|
|
Cobalt Neutra
As seen on radio
Join date: 13 Sep 2004
Posts: 48
|
05-25-2006 03:41
From: Cross Lament Try this version? This way it only toggled the sound at those instants when the forward control is first pressed or first released, instead of continuously triggering things (since you're using 'level' I assume you're also using the name 'edge' for the other variable  ) I gave your code a shot, and while it seemed to make the sound a little smoother, it also made the "gas pedal" only work as the key was pressed down - not held. Would seperate edge and level code sections work? I'm a little fuzzy on how the "held" and "change" integers work..
|