Download

Rotator and Vector Maths - Moving Pawn relative to its Yaw

I am moving a pawn +/- 10 units along the X, Y and Z axes (e.g. Vect(3, -4, 9))

This works great when it’s facing forward.

If I rotate (yaw only) a random number of degrees, how can I get the relative position it should now move to (e.g. move it 10 units along X, rotate 90 degrees, X becomes Y).

I tried MoveVector + Vector(Rotation), but that didn’t seem to work. It set it to just move along the X axis, but it was moving up and down and forward and backward as well!

Get a normalized vector of the pawn’s rotation and multiply by the distance you want it to move.

Thanks Chimera.

So the code would be:

Normal(Vector(Rotation)) * MoveVector?

So, slight wrinkle in the works.

OffSetRotation:‘0,8000,0’ Vector(OffSetRotation):‘0.72,0.69,0.00’ TempVector1:‘0.72,0.69,0.00’ ActualMove:’-0.38,0.00,0.00’ TempVector2:’-0.27,0.00,0.00’
OffSetRotation:’-769,8000,2116’ Vector(OffSetRotation):‘0.72,0.69,-0.07’ TempVector1:‘0.72,0.69,-0.07’ ActualMove:’-0.38,0.00,0.00’ TempVector2:’-0.27,0.00,-0.00’

In the first line:
OffSetRotation is just the current yaw of the pawn. TempVector1 is Normal(Vector(OffsetRotation)) ActualMove is the move I want to make (just x for now). TempVector2 is them multiplied together.

In the second line, it’s the full rotation of the pawn.

So it’s not quite doing what I need.

I need to convert the amount to move in X (-0.38) to the relative X/Y given the Yaw of 8000. If I’m twisted 90 degrees, for example, the original vector would need to look something like (0, 0.38, 0) after alteration. If I’m multiplying stuff by zero, that’s never going to happen.

Got it.

Move = MovementVector << OffsetRotation;