Endless Runner - Rotate Camera Around Player

Hello all,

I’m fairly new to the unreal engine, and have spent the last while working through a number of the tutorials. Most recently I’ve worked through the Endless Runner tutorial, and I’d like to expand upon this with some new features and functionality, some of the which I’ve figured out others have me stumped.

My main sticking point at the minute is being able to rotate the camera around the player character with the mouse (eventually with a view to having the player to aim and shoot, with the pawn rotating his upper body to aim at the cursor) without affecting his direction of movement.

Everything I have tried so far hasn’t achieved what I’m going for. I either end up unable to move the camera with the mouse (or it’s instantly reset due to the way the tutorial is forcing a rotation for the player), or I try and change the way the player movement works by getting something other than the controller rotation, but in this case A and D turn the player rather than have him strafe.

To summarise what I’m aiming for is:

  • Player moves forward at a constant speed and cannot change the direction he is running
  • A and D keys cause the player to strafe left and right
  • Mouse rotates the camera around the player, but does not change the direction he is moving in any way

If anyone could offer some advice or suggestions as to how I might best achieve this, I’d be very grateful.

Please assume the end of the Endless Runner tutorial is my starting point, and see attached some of the blueprints I’ve tried which haven’t been successful.

Disclaimer: This is my first post so if I’ve not explained myself particularly well or I’m missing some key info please let me know and I’ll resolve.

Thanks in advance

Best results you will get with separating character from camera.

To do so, you need understand how controls work in unreal:

  • player controller gets all input (or should get it)
  • then it process it and sends commands to player pawn

In your case you will have 2 pawns:

  • one that is character
  • second that is camera

Send jumping and running to character pawn.
Then send location and rotation (or transform) from character pawn to camera pawn.
Or simply in camera pawn (on event tick) get player pawn, cast to it and read character location

To smooth camera in camera pawn add spring arm and turn on camera lag, add some minimal lag for speed and rotation.

Fighting against camera in character pawn is quite hard, it was done for FPS and TPS, games like runners, or RTS should manage cameras on their own.

Thanks so much for the fast reply, greatly appreciated.

I must admit to some ignorance of how controls (and camera setup) behave in Unreal, I’ll endeavour to learnt this next.

To make sure I understand the concept of what you’re saying, would you say the following would be an approximate breakdown of what I should do next?

  • Create a separate camera pawn (blueprint?)
  • Create some form of link between the Camera and Player pawns so the camera remains at a fixed distance from the player at all times
  • Create a player controller blueprint, and move all control related functionality to here from the player character blueprint

I’ll investigate these camera settings you mention, but I think when the eventual goalis to have the mouse control camera to aim the player’s weapon, anything which causes delay may not be beneficial.

Also, as a bonus question. I was thinking, rather than using the rotation of the character to determine forward, I could use an arrow component which would rotate along with the character, so that when the character strafed the could look like they are running at 45 degrees, which looks better than a sideways sliding strafe, but “forward” would never change, and this arrow could be used for the forward movement. However I can’t seem to make this arrow independent of the character’s mesh rotation. Is there a way to do this and is this even a sensible idea?


Yes you should create TWO blueprint pawns.

Character blueprint will be receiving input but not directly, you need to have all axis and input events in player controller, then send orders from it to character blueprint.
Then you add pure camera blueprint, which will read location and rotation of Character Pawn, and then move camera to that desired location.

All that is a bit tricky:
If you just posses camera pawn then it will recive all input, and you do not want input events sent for camerea you want them for character pawn.
But if you posses character pawn, game will show you what is going on from character camera.

So you are forced to posses camera pawn.
Get input exclusively to player controller. Then player controller records it, and sends commands to character pawn. For eg. you make dispatcher in player controller that is “go right”. Character pawn should cast to player controller, then assign event to “go right dispatcher”. as parameter you just pass “Axis value of right direction” (that one you get from axis event).

As to bonus question:
If you setup camera pawn right, then you can use camera pawn forward vector as forward direction. Character pawn is made for first person mainly and it has some nice functionality when you are making FPS, but its usually fighting you when you try to make different kind of game.

And very simple solution toy yout bonus question:
If your game runs in only one direction (no circles or turning 90 deg). You can always get forward vector of character (or camera blueprint) and zero Z and X values (or Z and Y). This way you get vector that always points in running direction. Then normalize this vector. But I fear i undestood your question wrong, because this vector will be always 1,0,0 or 0,1,0.

General solution to forward vector (it is bit complicated):
Make camera blueprint. Every 1\10th (or so, event tick happens too fast) second remember location of character blueprint. Place camera blueprint root in previous location of character. Make camera bp rotation so it looks at new character location.
This way vector from camera blueprint root to character will always point forward (or in direction that character is moving). To smooth all camera movement add spring arm and camera lag. This should work even in levels that have circles or turns.

I think i have got most of what your asking is in the 3rd person setup with a few tweaks but the strafe???
theres no animation for it and if you attempt to do a move it literally just skates from left to right…

I see that in the past the best way was not always to use the Axis floats to do the speed of the direction…
but to store them and make a manually set via code or blueprint. this allows the camera to act independently and the pawn (guess the child parent thing is the object oriented version)
camera ---->SPringArm -----> Mesh -----> collider.

My issue with this is the amount of Posses booleans one for each starts to get confusing which ones are enabled for what action to get the right setup…

I remember Unity used a target point above characters head… and the cmaera code was to follow and smooth player… on input Ie mouse it would force the camera input there and after you moved with the WASD it would smooth back behind the player and continue like it was locked behind…

Im working on this m8 and will be back when i find anything new…