Download

Auto-adjusting camera BP (like dark souls or nintendo games) made simple

Here is a project with a quick and easy function that will give you the popular “auto-rotation based on movement” functionality seen in games like dark souls, or many nintendo games such as mario 64 and zelda ocarina of time. It’s efficient, and only requires 3 float variables that can all be adjusted. They are as follows:

-CamRotationFactor: multiplier that controls how much total rotation is added. think of this as the “speed” of your rotation. 1.0 would be the default, adding your exact y input to the yaw each frame.
-CamAngleExponent: exponent that controls how strong or weak “diagonal” input values in-between 0 and 1 are. 0 is default here, which means diagonals would not be affected. Values higher than 1 weaken diagonal influence, while values lower than 0 strengthen it.
-BaseVelocity: what your player’s default “running” speed is, that the function uses in order to scale the rotation speed if you are moving faster or slower in order to keep an “even” amount of rotation for all velocities. this also prevents instant starts/stops, and will prevent the camera from turning while running straight into walls.

The project here is just the default ThirdPersonBP example with the function added: https://www.dropbox.com/s/6bkkfpyisi…ngCam.zip?dl=0
Video: autoadjustingcam

No external blueprint needed: just add the 3 variables to your character BP and copy the function. The function should be called from your “input axis MoveRight” equivalent.

Using this with a spring arm with camera lag and rotation lag set to 2.0 and its absolutely perfect. Thanks!

Hello,
I polished this up and added a new feature to it. Now the camera takes into account how fast your player is moving in relation to a set “base velocity” value, and adjusts the rotation accordingly. What this means is that if your velocity is double the base velocity, the camera will rotate twice as fast. This also means the camera will no longer rotate when you run into and are stopped by a wall.

Once you add your “Base Velocity” variable, the only thing you need to change is the final multiplication that hooks into “add controller yaw input” from the original image. This is how it should look (i promoted my y axis value to a local variable named “y input” to make things cleaner; you don’t have to do this, just plug the y value from the above image):

And here is a video of it in action:
[video]https://streamable.com/o98q3q[/video]

The values I used in the video are:
-cam rotation factor: 0.22
-cam angle exponent: 0.5
-base velocity: 600

To clarify since I realized my thread title might cause confusion:

This is a function you add to your Player Blueprint itself, not a separate camera BP. This works by reading the Y axis of your movement input, and adding Yaw input to the character’s control rotation value.

The variables it needs are all floats, and they are as follows:
-CamRotationFactor: multiplier that controls how much total rotation is added, think of this as the “speed” of your rotation. 1.0 would be the default, adding your exact y input to the yaw each frame.
-CamAngleExponent: exponent that controls how strong or weak “diagonal” input values in-between 0 and 1 are. 0 is default here, which means diagonals would not be affected. Values higher than 0 weaken diagonal influence, while values lower than 0 strengthen it.
-BaseVelocity: what your player’s default “running” speed is, that the function uses in order to scale the rotation speed if you are moving faster or slower than it. this prevents instant starts/stops, and will prevent the camera from turning while running straight into walls.

Just wanted to say thank you for this, it works amazingly well and is elegant, as maths isn’t my strong point would you mind elaborating on what exactly each part does, for example you find out the power of (ABS of the move direction yaw, camera angle exponent).

I can’t find the address “cam Auto Adjust Rotation”

Sorry, I thought people could just follow the image, since everything important is right there and pretty simple. I attached a project to the OP post.

Hello,
that part of the code returns a multiplier to affect the diagonal rotation speed based on the exponent you set. It uses the Abs() because the player Y input might be negative, and we only want the positive value in the calculation. Everything begins to make more sense once you know what the power node does; It’s UE4’s blueprint version of the exponent. For example, if your value is 2 and you put it through the power node with an exponent value of 4, then it is effectively doing this behind the scenes: 2x2x2x2 = 16. Exponents work by multiplying the base number by itself a set number of times.

Now that we know this, if the y input is 1 or -1 (fully right or fully left), nothing will happen because 11 always returns 1 no matter how many times you multiply it. But, if the y input were any amount of diagonal, say, 0.7 (45 degrees), then it will begin to be affected. 0.7^4 would be 0.70.70.70.7 = 0.2401. This is why raising the angle exponent value causes your diagonal rotation to be weaker but not your full left/right.

The second group of nodes takes the length of the player’s current X and Y velocity and divides it by a base value that you set. If your base value is 600, and your velocity is 600, then 1/1 = 1, so nothing about the calculation has changed. But then look at if you had half (300/600 = 0.5) or double (1200/600 = 2), the calculation changes to make the rotation slower or faster.

Finally, we multiply the whole thing by a “total rotation factor”. This is just the same as the “speed” of your rotation. You either add the full value (1.0) or some fraction of it.