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?
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.
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
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.
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.
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.
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.