make the forward velocity go in the direction the camera is facing

I’ve been trying to find a simple way to make the character always move in the direction the camera is facing.
so if your moving forward and turn your camera left your momentum is also turned left to be aligned with the camera.
help would be appreciated since I haven’t been able to find any solution that works.

You can take the direction for the velocity from the forward vector of the camera.

How is it coded at the moment?

at the moment its just the 1st person template
after I have taken the direction for the velocity from the camera how do I change the current direction of velocity to this new one?

I saw another post where they used add movement input but the problem with that is that it also adds velocity instead of just changing it

The first person template uses the ACharacter class for its Pawn.
The CharacterMovementComponent has a property called User Controller Desired Rotation:

To use this, you will need to turn off Orient Rotation to Movement, and also turn off controller yaw in the Character (Pawn) itself.
image

This may or may not give you the behavior you want. (You might also want to turn up the allowed turn rate from the default.)

If this is not enough, then you have to mash the values directly.
Typically, the way you do this is:

  1. Calculate planar velocity (velocity without Z component)
  2. Calculate normalized planar camera forward vector (e g, ignore up/down)
  3. Scale normalized camera vector by velocity
  4. Compose the new desired velocity by taking Z from the old, and XY from the new.
  5. Set the velocity based on this new velocity vector.

If you do this, you can turn on Orient Rotation to Movement, to make sure the character faces the way it’s going.
You’ll have to do something like this every tick:

It may end up being janky, especially on a network, though.

1 Like

thanks for the response after some consideration I decided that ill just need to write my own CMC for the movement since I want to change the default movement a lot.
and with multiplayer a janky blueprint solution is probably not the best idea.

thanks for taking the time to help me out though