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
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.
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;
}
}
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
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?
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?
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.
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.