Search Unity

when cube hit wall

Discussion in 'Audio & Video' started by imotski, Nov 26, 2015.

  1. imotski

    imotski

    Joined:
    Jul 27, 2015
    Posts:
    39
    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);

    }

    }
    }
     
  2. Deleted User

    Deleted User

    Guest

    This should not be in the audio section but you would use OnCollisionEnter instead of OnTriggerEnter.