Hey peeps, need some help with Vector Math I’ve been stumped on for some time.

I’m working with a Mixamo Character model that has directional animations. In this case I’m trying to figure our the math to determine the amount of degrees the projectile is offset based on the Player’s forward vector to output a value at which angle the projectile was hit in order to play the correct animation. Help would be much appreciated.

Dot product of two vectors is cosine of angle. But with simple dot product you will not know if its 25deg to left or right. So you need 2 dot products.

First is between forward actor vector and NORMALIZED vector of player location to projectile location (or impact point)

Second is same stuff but between player right vector and player location to projectile location vector,

Now you should have angle from dot product of forward vector, then you determine if its left or right from sign of right vector product.

Also remember to always normalize vectors before feeding to dot product, and actual angle you get from arcus sinus function of dot product result.

You may also want angle on horizontal plane only, for that multiply all vectors by [1.1.0] then normalize.

Thanks for the Help Nawrot, I’ve almost got it. The The only problem now is that the Degrees are spitting back inverse results over Quadrant I & Quadrant III and Quadrant II & Quadrant IV.

This is my blueprint so far. BP_BoomerangCharacter is Player, and get controlled Pawn acts as the projectile in the case.

Here is what the results are kicking back:

I may be misunderstanding - but isn’t this rotation just the standard built-in LookAtVector node?

yeah Unreal does a lot of work for you unless you just love pain or something

like @OptimisticMonkey said - try the ‘find look at rotation’ should solve most of your problems & simplify this a lot!

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Rotator/FindLookatRotation/index.html

then use actor’s forward vector to fire your projectile

just right click n look at your options sometimes helps find these as well as a simple google search - good luck

The LookAtRotation is not exactly what I need. I need to determine an objects Degree Offset from the forward vector of the player. The player does not spawn the projectile, the projectile is thrown at the player. I tried the LookAtRotation just in case but I’m not getting any positive results from it.

was just trying to help you find an easier simpler way to achieve your goals, we all have a tendency to over complicate things sometimes I’ve seen developers make a page of calculations when a few simple nodes returned the same results.

tried looking at it from the projectile’s point of view yet?

tried hit result from the projectile to get possibly the normal or hit normal then comparing to your player actor’s forward vector or something similar?

check this & ignore most of it other than the results from breaking the ‘hit’ event & see if any of that might help:

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseOnHit/Blueprints/

(gives a lot of results to work with)

again good luck

@Shadenmonk - if none of this helps or has helped I did find this video that might be of some help:

(also shows setting up the animations)

To resolve the different quadrants, you want the Atan2() function, not just arc-cosine.

As “X” value put in “position dot forward” and as “Y” value put in “position dot right.”