Is it possible to trigger a sound effect once two actors are in close proximity?
Hey there!
I'm working on a game were two actors are flying around the screen. One of them is controlled by the user while the other flies around randomly. Is there any way that I could trigger a sound effect, say the sound of wind, when the two actors are close to each other?
Any help is greatly appreciated.
Cheers,
Andrei
Best Answers
-
tatiang Posts: 11,949
Sure. You can use the magnitude() function which is described in the Cookbook:
https://help.gamesalad.com/hc/en-us/articles/202699556-1-11-Glossary
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
-
tatiang Posts: 11,949
That looks right. Twenty pixels is a very small amount. You're measuring from one actor's center to the other actor's center. Does it work when you increase that value (e.g. 150)? If not, how are you changing or constraining game.HeroX and game.HeroY?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
Sweet! Thanks
Iv'e been at it for some time, but haven't been able to figure out how to use it. Can you give me some pointers as to how I can approach this using the magnitude function?
This is what I have been trying. Am I doing something wrong?
I changed it to a higher number of pixels and it worked! I didn't realize that the magnitude measures from the centre of the actor (it even said so in the cookbook, silly me). Thanks for the help tatiang.
You're welcome!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User