Get forward vector from pawn movement.

I’m trying to get the forward vector for my pawn movement, regardless of its aim. The ‘get forward vector’ function returns the forward facing vector of the actor in world rotation but I’m looking for a directional vector instead, so if the pawn is strafing (moving left but facing up in a top down game) the vector would return a straight left vector… so in essence the vector delta between the previous and current frame.

Is there a quick way to do this?

Thanks for any help!

While strafing, I would use a “Get Right Vector” instead of a “Get Forward Vector”, and use a “Get Forward Vector” when moving forward. In this way you should always be able to get which way you are going.

Except that with most games you can press both and get a mixed vector.

The direction should of course be somewhere, probably on a physics level of the root physics object in the actor. Most characters uses a cylinder for collision, I am not sure what data you can query out of this component, maybe something useful?

I’m controlling a pawn by clicking on a screen space point and the pawn goes there without changing rotation (the root SceneComponent never rotates), so it won’t be a straight strafe or forward vector… Would you suggest adding them all together to get its directional vector perhaps?

That would make sense, and if the ‘get forward vector’ returns negative values it will return backwards vectors as well when moving backwards, and adding ‘get right vector’+‘get left vector’+‘get forward vector’ should work I think…?

If there’s a better way to do it I’m all ears. :slight_smile:

For my use in this case more specifically: I want to create a component that is leading my pawn 200-300 units in front of its direction, I can then use that to lerp a camera so my camera will be leading my pawn’s action a bit, essentially making more screen space ahead of my pawn’s movement no matter what direction it’s going in.

It’ll be amazing let me tell ya!