Page 1 of 1
I can hear bad guys shooting from across the level!

Posted:
Sat Apr 21, 2007 3:46 pm
by d-soldier
.. Been doing some beta testing of my game, and I ran through it without killing the baddies (just in case someone might do that) and sure enough, as I'm in a totally different section of the map I can still hear them shooting at me (audio only)... Other then the "destory if off screen" (their paths cause them to go off screen frequently) can anyone think of a way to silence these guys when they are x distance from player?

Posted:
Sat Apr 21, 2007 4:59 pm
by Sgt. Sparky
make an actor variable called sound,
and use this
- Code: Select all
if(distance(x, 0, player.x, 0) > 100)sound = 0;
else
{
sound = 1;
}
and when that play the sound use:
- Code: Select all
PlaySound2("data/your_sound.wav", sound, 1, 0.000000);
I hope that helps.
....

Posted:
Sat Apr 21, 2007 6:17 pm
by d-soldier
So I made the actor variable called sound... (not very advanced when it comes to variables mind you)... so where do I put the:
if(distance(x, 0, player.x, 0) > 100)sound = 0;
else
{
sound = 1;
}
????

Posted:
Sat Apr 21, 2007 6:17 pm
by Sgt. Sparky
draw actor event for that badies

ugg

Posted:
Sat Apr 21, 2007 7:13 pm
by d-soldier
... doesnt seem to work... the laser(actor) is creates the sound upon it's creation, so I put the code-
------
if(distance(x, 0, player.x, 0) > 100)sound = 0;
else
{
sound = 1;
}
-----
in it's creation script (even tried draw actor script too) and removed the original create actor/play sound function and replaced with create actor/script -
-----
PlaySound2("data/your_sound.wav", sound, 1, 0.000000);
-----
And now I hear nothing... adjusted the x distance in the script, and even moved my "not drawn at startup" laser actor close to the action (just to be sure)... nothing... Any ideas? (and I did adjust the "player" actor name in the code to fit my game, btw)

Posted:
Sat Apr 21, 2007 9:26 pm
by Sgt. Sparky
hmmm,
if it is for when the lazer is created then just use for the whole thing,
- Code: Select all
if(distance(x, 0, y, 0) < 200)PlaySound2("data/your_sound.wav", sound, 1, 0.000000);
and you know you must change the data/your_sound to the exact sound stuff.
(click on variables/functions and the menu will pop up and click on playsound,
select the sound volume and location ect.

and you know what to do next

Ha!

Posted:
Sat Apr 21, 2007 9:47 pm
by d-soldier
... Nothing seemed to work until I changed the sound variable from actor to global, now it works perfectly! Thanks again - thats twice today!

Posted:
Sat Apr 21, 2007 9:47 pm
by Sgt. Sparky
xD
you're welcome, any time!
