Announcement

Collapse
No announcement yet.

Find Rotator Between 2 Directional Vectors?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Find Rotator Between 2 Directional Vectors?

    Hey guys, this one has left me stumped for days... I would really appreciate any advice you can give.

    I have 2 line traces and I need to know the exact rotator value (not the angle) between the two directional vectors. The first line trace uses the 'get forward vector' from the character weapon and goes straight out the muzzle into the world. The second line trace also uses the 'get forward vector' but it originates from a mesh that is not only orbiting around the player, but also playing an animation - thus its 'forward vector' could be pointing in literally any direction, depending on what part of the animation is playing. I use the start and end points of each line trace, respectively, with the 'Get Direction Vector' node to compute normalized directional vectors for both line traces (which are essentially the unit vectors of the debug lines).

    Ultimately, my goal is to be able to use the Lerp(Rotator) and SetRelativeRotation nodes to slowly rotate the orbiting mesh into facing the same direction the weapon is currently pointing, at the time the line traces are run. I see that I can use a dot product and the Arccos node to acquire the angle between the two directional vectors but I can't figure out how to find that angle of offset in terms of a roll, pitch and yaw rotator.

    Any thoughts? Is this even possible? Am I going about this the hardest possible way? Thanks.

    #2
    Sorry if I misunderstand what you're after, but if you want the orbiting mesh to face the same point that the weapon is aiming at, could you not just use the FindLookAtRotation node? The start point being the orb's location, and the target point would be the guns location + forward vector multiplied by some large amount to get a point somewhere out into the world in the direction the gun is facing.

    Comment


      #3
      Originally posted by SVR33 View Post
      Hey guys, this one has left me stumped for days... I would really appreciate any advice you can give.

      I have 2 line traces and I need to know the exact rotator value (not the angle) between the two directional vectors. The first line trace uses the 'get forward vector' from the character weapon and goes straight out the muzzle into the world. The second line trace also uses the 'get forward vector' but it originates from a mesh that is not only orbiting around the player, but also playing an animation - thus its 'forward vector' could be pointing in literally any direction, depending on what part of the animation is playing. I use the start and end points of each line trace, respectively, with the 'Get Direction Vector' node to compute normalized directional vectors for both line traces (which are essentially the unit vectors of the debug lines).

      Ultimately, my goal is to be able to use the Lerp(Rotator) and SetRelativeRotation nodes to slowly rotate the orbiting mesh into facing the same direction the weapon is currently pointing, at the time the line traces are run. I see that I can use a dot product and the Arccos node to acquire the angle between the two directional vectors but I can't figure out how to find that angle of offset in terms of a roll, pitch and yaw rotator.

      Any thoughts? Is this even possible? Am I going about this the hardest possible way? Thanks.
      Just use RInterp: https://answers.unrealengine.com/que...blueprint.html
      Btw, there are plenty of small useful functions like this in blueprints, check the Math collection of nodes for specific type of your variable (rotator, vector, float).
      Youtube Channel

      Comment

      Working...
      X