- Home /
Question by
KalibooStew · Jul 12, 2014 at 08:11 PM ·
2dphysicscolliderangle
Calculate the normal of a collider
I have a 2D game with two objects - the player (a circle) and rectangle (which can be rotated at any angle). The player can collide with this rectangle.
How can I calculate the normal line of the collider (by which I mean the angle at which the player hits the rectangle)?
Thanks
Comment
Best Answer
Answer by tanoshimi · Jul 12, 2014 at 09:02 PM
You don't need to calculate it - it's given to you in the Collision2D object passed to OnCollisionEnter2D: http://docs.unity3d.com/ScriptReference/ContactPoint2D-normal.html
Ahhh! I thought that was for something different but now I see that I was just being silly. Thanks very much :D