Why is CinemachineFreeLook Camera framerate dependant ?

Hi guys,

I’m using a third person cinemachine free look camera in my game and it seems to be framerate dependant when I test it.
I have an option to activate VSync or not (if On, it changes FPS to feat screen Hz).

If option is Off (so many FPS), camera movement are normal.
If option is On (so 60 FPS) camera movement are very slow.

I’m using Cinemachine 2.9.5 on Unity 2021.3.20.
Parameters used :

  • Input Value Gain for each Axis.
  • X axis Speed to 1 and Accel/Decel time to 0.01
  • Y axis with 0.015 Speed and Accel/Decel time to0.05
  • New Input system and Cinemachine Input provider.
  • Cinemachine Brain Update method to Smart Update (others create some shuderring)

I have read all potentials Issues on this subject but nothing for me.
What I have already tried :

  • Create a processor for Input system to decrease inputs using deltatime
  • Modify GetAxisValue return value in Custom Input Provider

Have you some ideas on this please ?
Thanks guys.

Hey @SIgmar_Storm .

[Previous post (Replied a bit to fast)]
It’s a regression :confused: we fixed and came back. Will be fixed ASAP. Thanks for reporting it.

[Edit]
Looks like it’s not the bug we previously had. Do you think you could be able to do a repro project of the issue with one VCam?

Let us know

1 Like

Hi, thanks for reply.

I’ve realised a test project with the same parameters listed above.
It seems to come from Input provider when using gamepad, mouse seems to be OK, but Gamepad mode is not.

You can test the build given in this zip with the rest of the project.
WeTransfer link WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free, this forum not allow big Zip file.

To reproduce,

  • Open the build given with the zip project
  • Just put the gamepad right stick to right/left side => Get the sensitivity in mind
  • Press F1 Key on your keyboard (Enable/Disable VSync)
  • Put again the gamepad right stick to a side => Slower than before.

Thanks

1 Like

Hi again :slight_smile: ,

The problem is controller joystick is not delta timed. For example:

  • If your stick on the right at 10 fps it will be updated 10 * 1 per seconds = 10 units.
  • With the stick on the right at 100 fps it will be updated 100 * 1 per seconds = 100 units.

Why doesn’t it happen with the mouse?
If you are at 10 fps or 100 fps moving physically the mouse 100 inch to the right the delta per frame will change but the total delta per second will be the same.

How to solve it?
We will see with the team if there is a way to improve this use case in a better way. The frame based joystick value makes sense in some use case and doesn’t in others.

In your case specifically you could use processors to make the joystick value delta timed. Simplest way would be to create a processor.

using UnityEngine;
using UnityEngine.InputSystem;
#if UNITY_EDITOR
using UnityEditor;
[InitializeOnLoad]
#endif
public class DeltaTimeProcessor : InputProcessor<Vector2>
{
#if UNITY_EDITOR
    static DeltaTimeProcessor()
    {
        Initialize();
    }
#endif
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    static void Initialize()
    {
        InputSystem.RegisterProcessor<DeltaTimeProcessor>();
    }
    public override Vector2 Process(Vector2 value, InputControl control)
    {
        return value * Time.deltaTime;
    }
}

And add this processor to your joystick action.

Let us know if this work for you.

5 Likes

Hi !

Thanks for the solution, it seems to work for the Test project.
I had already create and test this type of processor, but it was not working…

…and I know why :

During few tests I found a bug in Input Action Asset.

When you add a processor and save the input asset, sometimes the processor disappears.
I had to do it 5 times to have the processor saved with the inputs.

That’s why my previous try with processor failed, it was not saved :frowning:

Thanks

1 Like

Awesome you got it working!

Reported your issue with the input asset to the input team.

:slight_smile:

1 Like

Oh, that’s a great idea! I was just asking about this in another thread . I hadn’t thought of just adding a processor. Thanks!

I’m having this exact issue. I tried adding this Processor to the Input System, but then the input doesn’t register at all. I did some testing and realized it is the *Time.deltaTime part. If I remove it and add my own multiplier, it works again, but back to depending on framerate. Any ideas?

The * Time.deltaTime part is the whole point. What do you mean the input doesn’t register? It works for us.

1 Like

Whenever I add the Time.deltaTime the camera just won’t respond to input, at all. Without it, it responds slowly but depends on framerate.

using UnityEngine;
using UnityEngine.InputSystem;
#if UNITY_EDITOR
using UnityEditor;
[InitializeOnLoad]
#endif
public class DeltaTimeProcessor : InputProcessor<Vector2>
{
#if UNITY_EDITOR
    static DeltaTimeProcessor()
    {
        Initialize();
    }
#endif
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    static void Initialize()
    {
        InputSystem.RegisterProcessor<DeltaTimeProcessor>();
    }
    public override Vector2 Process(Vector2 value, InputControl control)
    {
        return value * Player_Controller.lookStickSensitivity/* * Time.deltaTime*/;
    }
}

I just added my own multiplier so the camera will respond faster, but it does still depend on framerate. The multiplier is a simple float. Whenever I leave the deltaTime, it will stop responding, when I remove it, it works.

That should not be happening. The processor is designed specifically to account for the deltaTime.
Do you have Time.timeScale set to 0?
Check the Input System Package settings. What is the Update Mode?

2 Likes

Time Scale is set to 1.
Everything in the Input System Package Settings is exactly as in your screenshot, triple-checked.

What happens if you add a break point on this line?

    public override Vector2 Process(Vector2 value, InputControl control)
    {
        return value * Player_Controller.lookStickSensitivity * Time.deltaTime;
    }

What’s the values of Time.deltaTime and Player_Controller.lookStickSensitivity?

2 Likes

Breakpoint returns Time.deltaTime as 0.016 at 60fps. Player_Controller.lookStickSensitivity is at 10.

Hey, no idea what happened with your replies, sorry about that (We can still see automoded stuff).

Do you think you could create a repro project?

1 Like

Sure, I’ll look into it. I will let you know once I upload it somewhere.

Did you also add a multiplier (scale vector) to the gamepad stick? It will move so slowly after the delta multiplication that it will appear as though it’s broken and nothing is happening. It is working but the numbers just become tiny (for obvious reasons). Try adding that scale vector (you might need a huge number ~1000), and see if that helps. Hope you can fix it, that’s what worked for me.

3 Likes

I can’t seem to catch a break, now I can’t upload the repro project to the sharing website. Lol.

It seems in Cinemachine 2.9.7 the input is always multiplied by deltaTime, this now creates issues for mouse input which is already a delta and shouldn’t be multiplied by deltaTime.

As far as I can tell the only way around this is to directly drive axis.Value.

With the input system you could use the processor above but with the legacy input system you need to drive it manually indeed.
Checking if we could make it work without having to do custom code will get back to you.

2 Likes