I’m wondering if Unity has a built-in way or if anyone knows how to work this out. At the time of a RigidBody colliding with a surface, how “direct” was the hit? How can we calculate the magnitude of that impact, where a glancing blow would be near-zero and directly against it would be 1 (or the rigidbody’s velocity.magnitude)? ![]()
Dot Product. Plug in normalized velocity and the surface normal, print the results. These results should range from -1 to 1, with 0 being parallel to the surface.
Use Abs to further massage the value so your expected range would be 0 for glancing and 1 for direct impact.
Make sure at the time of calculation your velocity is a reasonable value. Depending on your own code it may have already been altered by the collision so just cache it if so, otherwise you should be fine. Print everything.
1 Like