Third Person Camera that aligns to movement direction

Hello there,

I want to create a third person camera that automatically aligns to the direction of player movement over time, as seen e.g. in Dark Souls. You can rotate the camera freely to look in any direction, and likewise move freely in any other direction. When you walk towards the camera you push it out of the way, and later on drag it behind you, so the view normalizes to “behind the player” again automatically. In addition, you can instantly put the camera back behind the player with a button.

I took a look at the ThirdPerson templates that come with UE4. They pretty much do what I want, and the spring arm component is a great thing. What I am missing is the “pushing the camera” part. With the template setup, the camera is a child of the player pawn, which I think is not suitable for what I want. I think I’d need to constrain the camera to keep (when possible) keep a fixed distance to the pawn, and remain as stationary as possible (= inertia). This sure isn’t too hard with Unreals physics engine, but would I need to separate the camera from the Pawn for that? From what I read here, I’d need to set [FONT=Courier New]bTakeCameraControlWhenPossessed to [FONT=Courier New]false and create a separate camera component in… yeah, where? Is this even possible in Blueprint, or would I need to overwrite the PlayerController’s [FONT=Courier New]CalcCamera function?

Any hint is appreciated!

Thanks,
David

The Third Person template uses a spring arm component set to ‘absolute rotation’, which means it ignores it’s parent rotation. If you took that, but then added some code to slowly interpolate its rotation to be behind the pawn when it starts moving, I think it should work pretty well.

You may want to check the following settings which affect the camera/character rotation and orientation:

  • “Use Controller View Rotation” in both, CameraBoom and Camera
  • “Orient Rotation to Movement” in CharacterMovement component
  • “Use Controller Desired Rotation” in CharacterMovement component (you have toggle to show Advanced properties)
  • “Use Controller Rotation Pitch/Yaw/Roll” in Pawn Defaults (it’s easy to find when you search for “use controller”)

Hey James and !

Thanks for your replies. James, I tried what you suggested - I better not show you my blueprint, but what I basically did was: get the vector of the direction the pawn is moving in, used the ‘Rotation from XVector’ node to get a rotator and then tried interpolating between the current and desired rotation using an ‘RInterp To’ node. I directly set the value using ‘Set Control Rotation’ on the PlayerController. This works pretty well, I don’t really know how to interpret the ‘Interp Speed’ parameter and it starts going crazy when I walk directly towards the camera. I’m sure I can figure that out. That said, it doesn’t feel very ‘physical’. The camera in games like Dark Souls (or really a lot of 3rd person console games where you walk with the left stick and control the camera with the right one) behaves like it was a physical object with inertia trying to keep a distance to you. When you walk directly towards the camera, you will only very lightly shove it to the side. With my current solution, if it wouldn’t throw a fit, the camera would interpolate very quickly to go behind the player. I’m sure all this could be modeled with custom Blueprints, but wouldn’t it be easier to use the existing physics functionality for the camera?

, thanks for the list of properties. Most of them only affects the pawn though. If there was something like ‘Orient Rotation to Movement’ and ‘Rotation Rate’ for the CameraBoom, that would be perfect! I’ll take a look into the source and see if I can reuse it :slight_smile:

I had a quick look at a Dark Souls gameplay video and it looks to me that if you take the 3rd person template, then you need to set the following:

  • Camera component “Use controller rotation” - off
  • CameraBoom component “Use controller rotation” - on
  • CharacterMovement component “Orient Rotation to Movement” - on
  • CharacterMovement component “Use Controller Desired Rotation”" - off (but shouldn’t matter, above option overrides this)
  • Pawn Defaults “Use Controller Rotation Pitch/Yaw/Roll” - off all 3

Is that what are you after?

edit: If there is some automatic alignment of the camera to the pawn rotation, you will have to set that up manually like James said.

Hey ,

these are actually the default settings when you create a new TP_ThirdPerson project. With these settings the angle of the camera will never change until I move the mouse, which is not what I want.
More games I can think of are State Of Decay and Legend Of Zelda (at least Ocarina of Time). In contrast, games like Batman: Arkham Asylum (Unreal Engine 3 ;)) use the “fixed” camera style from the TP_ThirdPerson. Hope this helps to clarify.
If it’s still unclear, I can make a short video later demonstrating what I mean.

Thanks,
David

Yeah, i misread and I didn’t realize your main problem is to get the camera behind the player.
Depending on your desired effect, you will want to match the CameraBoom rotation to your pawn or controller rotation once the character moves and interpolate it over time just like James said.

Ok, I got something up and running. I’ll play around some more and post a solution :slight_smile: Thanks!

I created a video tutorial for anyone interested: https://www.youtube.com/watch?v=UMcmqsMzcFg

This is a fantastic tutorial, really useful and as you say, it behaves almost identical to the camera system in games like Dark Souls.

One thing that is slightly different however, is that the reset camera command snaps instantly into place. I was just wondering if anyone knows how to make this blend nicely instead? In Dark Souls/Zelda for example, when the reset button is clicked, the camera quickly rotates back to behind the pawn.

Hey Wolf, thanks for your feedback! I’ll look into it and make another quick tutorial when I got it.

That would be great, thanks! :slight_smile:

I got it working, I plan to record a short video tutorial about what I did tomorrow :slight_smile:

And here it is: https://www.youtube.com/watch?v=-M3zuRBVbzY
Hope it helps

Works like a dream! Thanks again :slight_smile:

i dont uderstud how it work, mb some one do video tutor step by step ?

Just a note - I’ve managed to replicate this in code, along with the smooth position reset. I will write up a tutorial for anyone who might need it. Thanks for the BP implementation.

1 Like