Freelook camera jumpy rotation when rotating in lower framerates

Hi!

I’ve come across a strange camera rotation behavior using Cinemachine Freelook.
Not all parts of our game have perfect 60 fps, so frame dips are expected, at least for some users.

Rotating the Freelook camera still result in the camera direction is more jumpy or jittery than expected.
(Tested also without a moving character just by setting Follow and LookAt on a stationary gamebject).

By jittering I mean that the camera tends to move in a staircase pattern rather than a diagonal when inputting for example .5f on x-axis and .5f on y-axis. It sometimes seems like the rotation movement jumps ahead of its expected movement. Comparing to other simpler camera rotations, the cameras still end up where you expect them to because input updates are done in the update-loop including Time.deltatime.

Settings:
The cinemachine brain is set to update on LateUpdate.
Freelook uses InputValueGain for both axis and I have tried updating the axis value both by manually setting them in update or using an extension RewiredCinemachineBridge but no difference there.
I have tried with and without using CinemachineCameraOffset.

Uploaded a screenshot of all the Freelook settings.

Scrolling through the forum for similar thread, all I found was something about InputValueGain having a framerate dependant bug. But I didn’t seem to get better results using MaxSpeed. Could this be related?

I am thankful for any leads!

Hi
Could you show a recording of the jittery rotation, or send us a sample project where we can reproduce it?
What Cinemachine and Unity version are you using?

I can try to set up a sample project.
Currently using Cinemachine Version 2.9.0-pre.6 and Unity 2021.2.19f1

I have sent you a repro sample project with a simple camera controller sending joystick input to the freelook input axis values. On one side of the “character” there is a large collection of meshes alpha textures generating a lot of drawcalls. Feel free to multiply these if you happen to be on a powerful pc.

The effect is most noticable in the build as opposed to in the editor window. And the jittering is most visible when rotating the camera in diagonals, as it seems like the Y-axis blends differently between the orbitals than rotating the X-axis. Lower framerate is of course expected to give choppy camera rotations, but the staircase pattern seen when rotating diagonally stands out as something different.

1 Like

Are you using the input system package?

We are using Rewired for our project, but for the sample repro project I’ve just set up Input.GetAxis(…) and use that for the
m_XAxis.m_InputAxisValue together with deltaTime.

I had a look at your project, and I think the problem is in your CameraController script.

When you set AxisState.m_InputAxisValue you should not be applying deltaTime, because the FreeLook will do that when processing the input value. As a result deltaTime is being squared. When I change your script to scale the input by a constant value, there is no unevenness in the motion.

using UnityEngine;
using Cinemachine;

public class CameraController : MonoBehaviour
{
    public CinemachineFreeLook freelook;
    public float Gain = 0.01f;
   
    // Update is called once per frame
    void Update()
    {
        var inputX = Input.GetAxis("Horizontal");
        freelook.m_XAxis.m_InputAxisValue = inputX * Gain;
           
        var inputY = Input.GetAxis("Vertical");
        freelook.m_YAxis.m_InputAxisValue = inputY * Gain;
    }
}

You would need to consider deltaTime if you were driving AxisState.Value directly.

1 Like