How do I make the camera sway with mouse movement?

Hello. I am slightly new to using Unreal Engine 5, and I was wondering how I would make a first person camera sway left and right using the mouse? Basically if I were to move the mouse (Camera) to the left quickly, the camera would sway to the left, and if I moved the mouse (Camera) to the right quickly, the camera would sway to the right.

Edit: I reached the maximum amount of replies so I would like to thank you Everynone for the help! Everything works now.

  • disable Control Rotation on the camera
  • have input set target rotator yaw using Combine Rotators
  • have Tick arrive at the desired relative camera rotation using rInterpTo

That’d achieve the described effect but may be insufficient (or straight up a wrong direction to take) - knowing what else needs to be considered could be critical here.

Could you provide photos so I can try it? Thanks!

How did you get the Set and Target nodes? I can not find them

Add a new variable.

I tried and the camera does not tilt when I move around, I will try a couple of other things and if I can not make it work, I’ll reply back

I have tried multiple solutions and I have not yet managed to make the camera tilt when turning. I am also using a SpringArm. I have tried without one and yet no result.

What I suggested above was done using the standard 1st person template. Perhaps I misunderstood the intent; here’s what the suggested script produces:

A single swing of the mouse in horizontal axis rotates the camera quickly at first and then comes to a stop. If in doubt, do post the setup and camera / springarm (if you’re using it - could also work for a lazy lag) settings.


If this is not the effect you’re after, consider describing it in more detail.

I will send the setup later, but basically what I meant by camera sway was that the camera would slightly rotate (Roll) to the left or right when the camera moves quickly.

Roll

This is clearly not the effect you’re after then.

Seems like it

Start here without using Control Rotation:

However, without knowing what else is needed from the camera behaviour, this may not be the right direction to take.

Something like this is the right step forward. The only thing I believe I need is for the rotation to spring back to normal, and for the roll to be more dynamic, such as the speed I turn at. Example: turning quickly which would roll (tilt) the camera strongly and slightly more, and then spring back to normal, but slowly turning would not roll (tilt) the camera

Like this? Target Roll is 0.

1 Like

That is exactly what I needed! I will try it out and I’ll tell you if anything goes wrong.

1 Like

It works but for some reason the camera tilting snaps instead of easing in/out

Again, it’s impossible to guess without seeing the script… Did you enter Interp Speed?

Yes I did, I have tried different values but the tilting snaps back instantly. Here is a photo of the blueprint. (Sorry if it is messy)

Looks more than fine at a glance. Try the same in a clean project. It’s probably caused by a setting we cannot see here.

1 Like