- Home /
More than one Sound Collision
Is there a way in Unity to make it possible for a certain object to have more than one sound collision script. I'm making a survival horror game sort of similar to slender and I would like to know if it is possible to play a certain sound when the enemy is distant and a different sound when the enemy is closer ?
Comment
Using Vector3.Distance ( zombie, player ) if this is within 10 meters, player louder sound else if within 20 meters, player softer sound
Thanks but would you be able to show it to me with a sort of sample code ?
Assume gameObjects Zombie and Player. if Vector3.Distance(Zombie.transform,Player.transform) < 10.0: audio.Play("Loud sound") else if Vector3.Distance(Zombie.transform,Player.transform) < 20.0: audio.Play("Soft sound")