Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!!

Product Version: Not Selected
more ▼

asked Jun 02 '14 at 10:02 PM in C++ Programming

avatar image

55 14 13 14

avatar image Exreph Jun 02 '14 at 11:40 PM

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!

avatar image P_Kras Jan 07 '16 at 02:41 PM

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

avatar image GuapoTaco101 Jan 07 '16 at 02:49 PM

Yeah, break hit result then get the normal vector.

avatar image P_Kras Jan 07 '16 at 03:24 PM

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

avatar image rantrod Jan 07 '16 at 10:16 PM
 float DotP = FVector::DotProduct(HitNormal, BulletForwardVector);
 float Angle = FMath::RadiansToDegrees(acosf(-DotP));

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

avatar image P_Kras Jan 07 '16 at 10:25 PM

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

avatar image rantrod Jan 07 '16 at 11:30 PM

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

avatar image P_Kras Jan 07 '16 at 11:51 PM

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.
avatar image rantrod Jan 08 '16 at 12:19 AM

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();

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question