Made a previous post concerning playing audio on collision, and ended up with this code…
#pragma strict
function Start () {
var play;
if pause = true
function OnCollisionEnter(collision : Collision) {
// Debug-draw all contact points and normals
for (var contact : ContactPoint in collision.contacts) {
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
// Play a sound if the coliding objects had a big impact.
if (collision.relativeVelocity.magnitude > 2)
audio.Play();
}
var pause;
if play = true
function OnCollisionEnter(collision : Collision) {
// Debug-draw all contact points and normals
for (var contact : ContactPoint in collision.contacts) {
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
// Play a sound if the coliding objects had a big impact.
if (collision.relativeVelocity.magnitude > 2)
audio.Pause();
}
}
function Update () {
}
I know there’s stuff wrong with it, but could someone just blunty tell me or fix it so I can learn from a side by side comparison? I’m not very good at learning in bits and pieces.
Thans - Sir Paddles of Loxely