Collision position

Hey guys,

I’m trying to work out a reaction force for collisions, and I figured the best way to do this would be to just look at the position-vector of the collision, and the position-vector of the centre of the player, and then say that a force is applied in the direction of the vector between those two.

However, I have no idea how to find out the position of where the collision takes place? I mean, Unity must calculate it to realise one polygon has hit another polygon… I want to know the position of the two polygons that are hitting. Is this possible?

Thanks if anyone can help me out here.
Stephen

Hey, thanks - I don’t know why I couldn’t find that page to start with :expressionless:

But now I’m stuck using the code, I’ve put it in but it doesn’t seem to activate itself,

function OnCollisionEnter(collision : Collision){
	var shipHandleScript:shipHandleScript = transform.parent.parent.GetComponent("shipHandleScript");
	for(var contact:ContactPoint in collision.contacts){
		Debug.Log(1);
		shipHandleScript.shipForce -= shipHandleScript.shipVelocity.magnitude * Vector3.Normalize(transform.position - contact.point) * Time.deltaTime * 50000;
	}
}

I’ve got that in, but it does nothing when the transform collides with something else. (I know the collision is valid because my code from an OnTriggerEnter runs just fine)

Is there a rigidbody on the object with the script? You can switch on its Is Kinematic option if you don’t want the object to have physics.

Hey, yeah there is a Rigidbody attached to the object with the script. I can’t work out what’s wrong :expressionless:

Maybe my structure with the rigidbody and colliders etc. is wrong? I have…

Ship ← (Contains OnCollisionEnter script)
-Colliders
–ColliderMain ← (Contains rigidbody and collider)

Building
-Colliders
–ColliderMain ← (Contains collider)

Does this seem right?