Hello, I'm totally new on unity. I have sound source and my question is how can I play that sound when my cube hit a wall? I tried something like this, but it doesn't work. usingUnityEngine; usingSystem.Collections; public class sound : MonoBehaviour { voidOnTriggerEnter (Colliderother) { if(other.gameObject.tag == "wall") { Audio.PlayOneShot(sound); } } }
This should not be in the audio section but you would use OnCollisionEnter instead of OnTriggerEnter.