var soundClip : AudioClip;
function OnTriggerEnter (collision : Collision) {
audio.clip = soundClip;
audio.Play();
}
function OnCollisionExit (collision : Collision) {
audio.Stop(soundClip);
}
Why is this not working?
Errors:
Script error: OnTriggerEnter
This message parameter has to be of type: Collider
The message will be ignored.
Assets/Piano.js(17,15): BCE0017: The best overload for the method ‘UnityEngine.AudioSource.Stop()’ is not compatible with the argument list ‘(UnityEngine.AudioClip)’.
I have never used a collider, but the error message is telling you that it is expecting the “collider” type instead of the “collision” type for your OnTriggerEnter function.