- Home /
Question by
Darwin Mecharov · Apr 10, 2014 at 01:39 PM ·
javascriptaudioaudiosourcedistanceaudiolistener
How do I only start the audio when player is at max distance
Hello guys! I have a problem with my game. I figured out how to play the audio on max distance but I don't know how to start it when the player enters the max distance area. Can anyone help me? Or give me a sample command for it?
Oh, and what's with my suggested tags being "i have not slept in days" and "gui-problem", not related at all.
Comment
What do you mean by max distance? Are you talking about the range of 3D audio sounds?
Best Answer
Answer by MaT227 · Apr 10, 2014 at 01:43 PM
You attach a sphere collider on your AudioSource and a script with OnTriggerEnter. Then when the player enter the trigger you can use Play to play the sound.
Never$$anonymous$$d, I figured it out with Vector3.sqr$$anonymous$$agnitude. Well, I'll keep this in $$anonymous$$d.