- Home /
Question by
Skyesofrock · Mar 20, 2013 at 01:02 PM ·
c#collisionaudio
Audio on Collision not working C#
I've trawled Unity Answers for some examples of code playing audio on collision, and come up with some code.. but it doesn't work. I'm not sure why either.
Basically, I have a box that I want the player to be able to jump on, and I want to play a sound when they land on the box. The script is attached to the box, and this is how it looks at the moment:
[RequireComponent(typeof(AudioClip))]
public class landing : MonoBehaviour {
public AudioClip land;
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Player")
audio.PlayOneShot(land, 1);
}
I have no idea where I'm going wrong.. The audio is Ogg Vorbis, but it still refuses to play.
Any ideas?
Comment
Your answer

Follow this Question
Related Questions
Sounds triggering too fast 4 Answers
Sound plays right at the beginning 2 Answers
Dynamic collision sound system (c#) 1 Answer
Multiple Cars not working 1 Answer
Yet another Audio on Collision issue 1 Answer