Hi sorry I tried searching the forum for a good example of what I am trying to do, but I didn’t find anything. I am trying to script everything out on my game without having to use the GUI because I plan on switching out the models later so I don’t want to attach too much to them.
So I have all my physics done and it is working as I intend it to. Now I want to have reactions on collision like sound or adjustments. I have looked at the documentation, but on the below script how does it determine what object it is detecting collision for? I figure it is probably because the script has to be attached to the model. Can I just do MODEL.addcomponent(SCRIPTNAME)?
Is there anyway to actually tell it what model we are checking for collision on so I can have 1 script with all my collision?
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();
}
also what is (collision : Collision)?
I know there is a collision class, but a lot of it is read only.