Hello guys,
I’m starting a new project and I have some issue with the new Input System. I get multiple callbacks in one frame for my input. But it’s not consistent, some frame it’s OK, some frame i get 2 or 3 callback calls.
This is my example :
using UnityEngine;
using UnityEngine.InputSystem;
public class Controller : MonoBehaviour
{
private GameInputs m_Inputs;
private int m_ProcessFrame = -1;
void Start()
{
Debug.Log("Controller is started");
m_Inputs = new GameInputs();
m_Inputs.Player.Enable();
m_Inputs.Player.Movement.performed += OnInputs;
}
private void OnDestroy()
{
Debug.Log("Controller is destroyed");
m_Inputs.Player.Movement.performed -= OnInputs;
m_Inputs.Player.Disable();
}
public void OnInputs(InputAction.CallbackContext context)
{
int currentFrame = Time.frameCount;
Vector2 val = context.ReadValue<Vector2>();
if (m_ProcessFrame != currentFrame)
{
Debug.Log(Time.frameCount + $": {context.action} get call back with values {val.x}/{val.y}");
m_ProcessFrame = currentFrame;
}
else
{
Debug.LogWarning(Time.frameCount + $": {context.action} already get call back. These are the new values {val.x}/{val.y}");
}
}
}
As you can see on the image I added to this thread, i get a warning saying that I get multiple callback on the same frame. In addition, we can see the value is different between the same frame.
You can see the see the settings I have. I changed the update mode to be during “Dynamic Update”.
Am i alone with this problem? What do you guys think?
Unity version : 2019.1.9f1
Input System version : preview - 0.2.10