0
\$\begingroup\$

I want to calculate the relative angle of the speed in relation to the direction of view:

Angle

For this I do have the "Get Control Rotation" and the "Get Velocity" of the "Pawn"

I am stuck:

enter image description here

Yeah I stole the original image from: https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/74282-get-angle-offset-from-forward-vector-need-help

But it explains exactly how the "angle" should be.

Positive values if the velocity is "moving to the right" relative to the looking direction and negative values if "moving left".

EDIT:

Using arctan I can compute the negative and positive angle based on the horizontal components of the vector. As I am only interested in horizontal movement and the horizontal "direction" in which my pawn is facing.

As the "forward vector" of the rotator uses a "z" component when looking up/down I figured I could use the "right vector" and rotate it -90 degress (to the left or better say front) around the "z" axis, because it never get's a "z" value.

Unfortunetly if the velocity vector has a "z" value when moving sidewards up or down the hill the angle is +270 instead of -90 and reverse:

NewMacro

\$\endgroup\$
2
  • \$\begingroup\$ What format is your rotation in? \$\endgroup\$
    – DMGregory
    May 17, 2020 at 21:25
  • \$\begingroup\$ It's a rotator with XYZ axis \$\endgroup\$
    – Pwnstar
    May 18, 2020 at 6:55

1 Answer 1

0
\$\begingroup\$

The problem with my solution was that whenever I do have a large angle (more than +/- 90 degrees) the calculation was not right so I added the following in between:

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .