'Getting yaw angle between two actors - Unreal Blueprints

I'm working on a VR game in Unreal Engine 4 using Blueprints.

I want to calculate the (yaw) angle the user needs to turn his/her gun (whose direction is determined via the position of the motion controllers) in order to be pointing towards the target.

I figure this might be the way to do it:

  • Subtract the location of the target from the location of the gun
  • Get the yaw component of that as a vector pointing from the gun as origin
  • Subtract the current yaw of the gun direction from that yaw component to get the yaw angle the user needs to turn to get to the target

Except I'm not quite sure how to execute that. I've been experimenting (as seen in the screenshot below), but not doing the correct operations. Any thoughts?

Thanks!

Unreal Engine 4 screenshot



Solution 1:[1]

This is how I do it: Finding angle between two actors with 'Find look at rotation'

'Find look at rotation' is a function from 'Kismet Math Library' (unreal math library). It finds world rotation for an object at Start location to point at Target location.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NobodySomewhere