Is it possible to switch between different sounds in a lowlevel command?
I have a vehicle that operates in lowlevel commands
accelerates when spacebar is pressed
brakes when B is pressed..............exct.
I was hoping to have a sound for acceleration, one for full speed, one for braking and deceleration.
I tried using
if(IsKeyDown(46))
{
if(speed<10)
{
PlaySound("accelerate.wav");
}
else
{
if(speed>10)
{
PlaySound("fullspeed.wav");
}
}
}
which kind of works....except i see no way of stopping accelerate.wav.
Am I overlooking something or is this not possible?
switching between sounds
Re: switching between sounds
I am not a scripter, but maybe: How about saying if the speed is greater than 1 or less than ten, play accelerate, else if speed is less than one, play no sound?creekmonkey wrote:Is it possible to switch between different sounds in a lowlevel command?
I have a vehicle that operates in lowlevel commands
accelerates when spacebar is pressed
brakes when B is pressed..............exct.
I was hoping to have a sound for acceleration, one for full speed, one for braking and deceleration.
I tried using
if(IsKeyDown(46))
{
if(speed<10)
{
PlaySound("accelerate.wav");
}
else
{
if(speed>10)
{
PlaySound("fullspeed.wav");
}
}
}
which kind of works....except i see no way of stopping accelerate.wav.
Am I overlooking something or is this not possible?
Steve Dilworth - Resisting change since 1965!
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
Re: switching between sounds
My problem is the sounds are overlapping, once my wav file starts it doesnt stop until finished no matter what i try. It seems ther is no LowLevel command to stop sounds.
Im sure there is probably some way to make acceptable vehicle sounds, I just cant get it to work. Maybe Juutis, QOD, bernie or one of the other scripting gurus have had some luck with this.
Im sure there is probably some way to make acceptable vehicle sounds, I just cant get it to work. Maybe Juutis, QOD, bernie or one of the other scripting gurus have had some luck with this.
Re: switching between sounds
Oh ya, I now I get your problem. I came up with a couple of possible solutions:
1.) Make the sounds very short.
2.) Add a timer so a new sound can only start when the old is finished. So for example if your sounds are 2 seconds long:
3.) I don't know if this works but using the AudioSource3D entity is one option. If turning the trigger for the entity off stops the sound immediately, it would work. But you'll have to test this yourself.
1.) Make the sounds very short.
2.) Add a timer so a new sound can only start when the old is finished. So for example if your sounds are 2 seconds long:
Code: Select all
if(soundtimer < time)
{
if(IsKeyDown(46))
{
if(speed<10)
{
PlaySound("accelerate.wav");
}
else
{
if(speed>10)
{
PlaySound("fullspeed.wav");
}
}
}
soundtimer = time + 2;
}
Pain is only psychological.
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
Re: switching between sounds
I was able to get the sounds fairly close using the audiosource3d.
It took a lot of ugly scripting, but it works.
4 triggers
4 audiosorce3d entities
and a ton of SetEventState(char *Trigger, bool State ).
The sounds are not the best but its way closer than I was.
It took a lot of ugly scripting, but it works.
4 triggers
4 audiosorce3d entities
and a ton of SetEventState(char *Trigger, bool State ).
The sounds are not the best but its way closer than I was.