Tilt camera when player moves left and right unity

116 views Asked by At

I tried to implement this effect, similar to this: https://www.reddit.com/r/Unity3D/comments/12kn33e/i_added_camera_tilt_based_on_the_movement_of_the/, using Lerp to smooth out the camera tilts, but was only able to get it working "snappily", ie. without lerp.

How could I get an effect similar to the one on reddit?

2

There are 2 answers

0
xLisiq On

Hard to answer since I have no code, but usually smoothness is achieved by increasing your camera tilt over time, until it reaches the maximum tilt value.

Here's an abstract example of how to do that:

currentTilt += Time.deltaTime * maximumTilt * 2;

Try using it somewhere in your code, may work. If it doesn't - edit your question and add some of your code so I have more info on your issue.

0
Absinthe On

As others have posted you should really post what code you've tried, as per site rules.

The effect you're looking for is probably provided by Vector3.SmoothDamp: https://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html

Use it to smooth out both the position and rotation (using Quaterion.Euler).