Dynamic tilt to first person character camera?

Hello!

My question is that in the game you can see in the video, there is a cool feature. When you move the character (the camera) with the mouse, there is a “tilt” effect on it, which I think really improves the camera dynamics. My question would be, how could this be implemented? Thanks! <3

Example:

So I figured out a semi-simple way to do this. You’ll want to detach the camera from control rotation and update it every second- using the relative X rotation to tilt.

First things first, the setup. We need to disable “Use Pawn Control Rotation” on the camera and add our X input value to a float we create:

You can add a divide or multiply node to the ActionValueX before adding it to tilt if you want a higher or lower tilt speed. To make it obvious, I didn’t, but you probably should.



In tick, we will do the bulk of the actual tilt. This section will solely be responsible for decreasing the tilt and preventing it from going outside our desired values.


This is just subtracting a small portion of tilt from itself. We plug it into deltatime as well to make sure we don’t change the speed due to framerate. For this, I’ve just set TiltRecoverSpeed to 5; the higher the TileRecoverSpeed, the quicker the camera will snap back. Conveniently, this already works with both positive and negatives since we’re multiplying Tilt (which we’re doing to make it snap back faster the more tilt there is).
image


The section just after it is to make sure we clamp in the right direction. If it’s positive, we want to have values between 0 and MaxTilt (I used 10) and if it’s negative, we want it to clamp between -10 and 0. The order is important since it’s min/max. The reason we don’t just clamp between -10 and 10 is because we want to actually stop at 0 rather than bounce back and forth for eternity.


And finally, the easiest part. We just update the rotation. We first set the world rotation of the camera to match the control rotation- so much will break if you don’t due to the fact we’re using an add rotation node right after. Speaking of the Add Relative Rotation node right after, we use it to simply add the tilt as our Delta Rotation X.

(You can get the node to look like mine does by right clicking and clicking split struct pin)
image

1 Like

Oh, my gosh! Thank you very much for the detailed answer and description! I will try it in my own project! <3

1 Like

Maybe you could elaborate a bit on the second picture, how you added the X and Y variables to the Enhanced Input?

I didn’t add anything to the action per-se. That was just the default first person camera input section.
However, look does by default come as a Vector2D. To recreate the exact look, you can right click and click split struct pin. You can also just use a break node.
image

The input itself is just the standard Axis2D mouse movement action.
image
image

1 Like