Hi everyone,
I have a pretty simple setup to destroy a crate and I encounter a problem quite randomly. When I destroy a crate everything works fine; when I have 2 or 3 crates close to each other and hit one, it instantiates as many instances that the editor freezes.
Here's is the crate code I use :
var Wreck : GameObject;
function OnCollisionEnter(collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
Instantiate (Wreck, transform.position, transform.rotation);
Destroy (gameObject);
}
and here is the rather simple weapon code:
var projectile : Rigidbody;
function Update () {
if (Input.GetButtonDown("Fire1")) {
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.forward * 40);
}
}
Thanks in advance for your help!