Top Down - Player movement to match camera rotation?

hi,
I guess you use the “add movement” node that is given by the character class. What the developers suggest is to set the controller rotation, get the rotation of the very same controller and convert that to a vector by the “get right vector” / “get forward vector” functions to use it as input for the add movement function. https://docs.unrealengine.com/latest/images/Gameplay/HowTo/CharacterMovement/Blueprints/Setup_2/Character_Movement.png

If you haven’t done it yet, you should create a project with the third person template and open the ThirdPersonCharacter Blueprint.

You might want to look through the dokumentation for character setup: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/CharacterMovement/Blueprints/index.html

Another way would be to use the “RotateVector” function on your already existing input and send it to the the AddMovement function.

1 Like

Hello,

Essentially what I have set up right now is that when I press “Q” or “E” my camera spring arm rotates around my pawn 90 degrees in the respective directions.

Now the problem I’m having is when I rotate the camera I can’t figure out how to get it so my players movement input rotates as well.

For example: If I’m pressing “W” to move forward and then I rotate my camera 90 degrees I want my player to turn and move forward in the direction the camera is now facing. All it does now is it keeps moving forward in the original direction and I now see the side of the player.

Here is a gif of what it’s currently doing…

202311-ue4camerarotation.gif

So after searching through the Third Person Template for the special magic that allows the character to walk forward in the direction the camera is facing, I found that there wasn’t much special that lets that happen. But I did manage to solve my problem from doing so. I decided since the Third Person Character already has a “camera view based movement” system by default where as the Top Down was designed for point and click and not camera magic. I replaced the Third Person camera setup with mine and transferred all of my other code over. That way there was none of that “move mouse to look” functionality that I don’t want. I did how ever keep the node behind the “mouse look.”

This is the blueprint setup that allows the camera to rotate 90 degrees in either direction around the player via custom input titled “CameraRotateLeft” and “CameraRotateRight”.

In order to get my player to also change his forward motion when I press “W” to match the new direction the camera is looking, I use the “Add Controller Yaw Input” node that was previously used to allow the mouse to move the cameraboom around the player and thus changing the movement direction.

I did try to use this same node setup in the Top Down Character’s Blueprint but it doesn’t work. I’m not sure why it only works with the Third Person Character and not the Top Down Character but it’s no big deal.

Here is a gif of the final camera product in action working as I originally intended it.

202334-ue4cameracontrolsolution.gif

As you can see, when the camera rotates 90 degrees while pressing “W” to walk forward, the player automatically changes his forward motion to match the forward view of the camera. I also do the twirl to show that all other directions are still in tact and that the player can move independently of whichever direction the camera is facing.

1 Like

how would you animate the rotation? Once you activate that rotation instead of snapping in to place put some movement into place?

oh joy, 404 not found. thanks ebic