How can I find the angle at which a Projectile hits a mesh?

Hey all, I am wondering if there is a way to see at what angle a projectile is coming into some kind of collision mesh. I am trying to create a bullet system where the incoming angle of the projectile decides weather it bounces or penetrates based on the angle.

Thank you!!

You could try using the Break Hit Result and get the impact transform. Might have to do some trig using that transform and the transform of where the bullet came from in order to get the angle you’re looking for. Since I’d think it’s 3D, and lets say someone is high up in the level on a hill and shoots down at someone else, that angle of “penetrate or bounce” would be different math than if those players were level with each other etc.

Due to that fact I would try to calculate this angle based on the normal of the mesh you hit, this way the 3D position will be easier to deal with.

However, the Impact Transform might take care of that for you. I haven’t used it myself, but it might be just what you need. Good luck!

Hello! Had you resolved this problem? If yes, how did you do it? Thanks.

Yeah, break hit result then get the normal vector.

What are you doing with normal vector to get an angle?

float DotP = FVector::DotProduct(HitNormal, BulletForwardVector);
float Angle = FMath::RadiansToDegrees(acosf(-DotP));

  • note, the math work because both vectors in question are already normalized

I’ve tried that but results was strange.
Angle always was 90°±10 or 175°±5.

That math is correct so something else has to be wrong. Perhaps the bullet is not oriented in the direction it’s going?

Perhaps the bullet is not oriented in the direction it’s going?
I think so. And I don’t understand why your method should work. Nobody can guarantee bullet orientation.

Whoever programs the bullet can definitely guarantee it. However, if bullet orientation doesn’t work, you can use the bullet velocity instead (normalized). If the bullet can be moved by outside factors, you can always have a post physics tick that does Dir = (CurrentPosition - LastFramesPosition).Normalize();