No sound on collision - Simple problem

Hi everyone,

I’m new at Unity, but i’ve tried many different options for this which would not compile. Currently, this .js will sit happily on my object:

#pragmastrict

public var Xylo_13: AudioClip;
var audi: AudioSource;

function Start() {
audi = GetComponent.();
audi.PlayOneShot(Xylo_13, 0.7F);
}

function Update () {

}

However, this is simply an elaborate way of saying “play on awake”. I included a screen-shot; where you can see that the inspector shows the audio source (Audi) and also has a space for the “sound” itself (Xylo_13), although that is already attached to the object so I’m not sure why it’s there.

Could someone help me to modify this code so that it plays when the player collides with the object? I’m making a space where you can jump diagonally up a piano keyboard and I want it to trigger piano sounds.

One other issue is that I do not want to set my Mesh Collider to convex, so I can’t select “is trigger”.

Sorry to post such a basic question; I have visited the “playoneshot” Unity manual page and tried the example code but no matter how hard I try I can’t get this to work.

2371218--161079--Screen Shot 2015-11-06 at 12.42.32.png

Start() is a function that is called once after the object is created. It seems you are looking for OnCollisionEnter: Unity - Scripting API: MonoBehaviour.OnCollisionEnter(Collision)