- Home /
Collision Normal
Hey guys,
Is there anyway to return the normal angle of a collision?
I've done some searching but really struggling to find a solution.
Thanks in advance!
-Jack
edit
Sorry the purpose is to rotate the other object away from the collision ;)
Answer by poncho · Apr 19, 2011 at 01:50 PM
with a Collision object use the collision.contacts[0].normal if there are more contact points you could use them, but usually the first one is the one you need
example
void OnCollisionEnter(Collision collisionInfo)
{
Vector3 myCollisionNormal = collisionInfo.contacts[0].normal;
}
Thanks! I had a feeling I was missing something obvious.
Is that the normal to the current objects collider at the contact point? Or the other object's?
is the normal of the contact point of the object that is subscribed to the script
lets say i had a ball with this script, i detected the collision, and the normal will have the normal vector of the surface i got the collision with, hope i explained myself
This is exactly what I was looking for. However, being new I don't know enough of the context to be able to use this. Could you help out?
Say for instance I have a player object and a wall object, how would I use this to find the normal angle of the wall object when the player object collides with it?
Could I make this function return a Vector3 so i can add it to the player object?
Your answer
Follow this Question
Related Questions
Collisions, Getting the Normal of the Collision Surface (Not the Angle of Impact) 1 Answer
Get angle to retarget collision object. 1 Answer
Obtaining contact point and normal of first object in collision 0 Answers
Average of Normals 1 Answer
exact vector reflection along collision normal vector 1 Answer