Hey all. While experimenting with CGE I began to address the issue of ambient sounds that only play if you're near an object. I have found a sort of way to do this. Let's say you want to have a waterfall that plays "Waterfall.aiff" if you get close by.
Create a new Global called: gb_Closeby
Create a new event called: "CloseBySound"
in the event:
(Event: CloseBySound)
Conditional:
If CloseBy = 1 then
Play Sound: "Waterfall.aiff"
Else
End Event
In the animation for the waterfall, add this event onto one of the frames.
Now go to the map that you want the waterfall to be in. Place the waterfall. Now in the events part of the map, create a new event. Call it: "Closeby0"
(Event: Closeby0)
Change Globals: Set gb_CloseBy = 0
Create another one entitled: Closeby1
(Event: Closeby1)
Change Globals: Set gb_CloseBy = 1
Now make a circle around the waterfall of the event: CloseBy0. Make it big enough so the player cannot see the waterfall, but will if he moves 1 tile in. Now make a circle of the event: CloseBy1 directly inside the circle of CloseBy0. 1 Tile inwards.
This way, when the player sees the waterfall, the sound will play.
You could also make it a fading sound, in which case you would have to make 3 different versions of the sound, each quieter than the last. Then in the CloseBySound event, you would have to make 3 conditionals that check for each variable, and play each sound accordingly, each one checking for a higher value of gb_CloseBy. Finally, you would have to make additional map events such as: CloseBy2, CloseBy3, etc., and make those circles around the waterfall, loudest towards the center, and of course CloseBy0 would have to be on the outside. This would make it fade as you walk closer to the waterfall. The downside to this is that it is so much more complicated than just one sound.
The only downside to this is that you would have to make additional events and globals if you wanted to have more than one object have a position detecting ambient sound.
Have fun, and good luck with your games.
------------------
"Stiney! Get me a danish!"
(This message has been edited by OgreBob (edited 09-27-2003).)