How can I make a sound play when the player goes through something that doesn’t have any colliders.
- Felipe
How can I make a sound play when the player goes through something that doesn’t have any colliders.
There’s a couple options:
You can detect distance and play the sound when you’re close enough. Running something like this in a MonoBehaviour.Update function would get that done:
if( (transform.position - target.transform.position).sqrMagnitude < someThreshold )
PlaySound();
Or you can make the object have a collider that’s a tigger and use the MonoBehaviour.OnTriggerEnter function. This is the more efficient way since it uses the engine to detect collisions.