0
\$\begingroup\$

In Unity3D, I can get the normal of the surface with which the collider collides using hit.normal, but is there a way to find which side has been hit with what is provided by Unity3D?

One solution is to see the orientation of the normal, and should work well for static objects but what about dynamic and moving objects whose orientation changes?

\$\endgroup\$
1
  • \$\begingroup\$ Exactly what you need to do depends on what data you have got and how it is represented, you should specify that exactly. Knowing that, someone can probably figure a matrix multiplication for the job, I'm not very strong in that field so I'll leave that to someone else. If you don't get a suitable here you could ask on math.stackexchange.com a lot of users on that site will find the mathematical part of this problem pretty casual. \$\endgroup\$ Sep 17, 2011 at 18:13

1 Answer 1

2
\$\begingroup\$

Try the following: Translate the hit.normal into the local space of your collider (via InverseTransformDirection), then compare the sign of the vector coordinates to the local directions.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .