Download

Is it possible to detect the angle a sphere trace hits at?

Hey guys! I’ve been wondering for a few days if its possible to get the angle a sphere trace hits at, and if so, how to it. For example, i want to be able to find the value of the hit being in the direct front of the sphere, vs the hit being slightly to the side like these example images.

Any help would be greatly appreciated!

https://preview.redd.it/r253d0f87fs41.png?width=1411

Hi, I’m assuming that you want the angle relative to the direction in which the sphere trace was fired. In that scenario, you’ll need two vectors before finding the angle between them.

The first one along the trace path can be obtained by finding the Unit Direction vector from your “Trace Start” location to “Trace End” location. The second one can be calculated by finding the Unit Direction vector from the Hit “Location” (the center of the sphere the moment it hits a blocking object) to the Hit “Impact Point” (the actual contact point between the sphere and the blocking object). Once you have these vectors, its just a matter of finding the angle between them.

Exactly what I was looking for! Thank you!!!