Hey guys
I’m making a simple action where a spaceship needs to collide with an asteroid, and the code I’m using for it is here:
var explosionPrefab : Transform;
function OnCollisionEnter(collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
var rot : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal);
var pos : Vector3 = contact.point;
Instantiate (explosionPrefab, pos, rot);
Destroy (gameObject);
}
I personally can’t see anything wrong with this, as I’ve set both the spaceship and the object with non-kinematic RigidBodies, and Unity doesn’t warn me of any scripting mistakes, but whenever I try to crash into an asteroid, the ship goes right through it, with no explosion effect. Can someone please help me with this, as I need the project to be submitted later today?enter code here
Thanks
Harry