Delay between Time.time and InputSystem.InputAction.CallbackContext.startTime

Hello !
I’m working on a Movement system using Unity’s new Input System, I thought I understood everything but apparently no : I was trying to get the time since the player pressed Shift to use it into a Arctan function or something to have an acceleration over time, so I’ve read the doc and saw that startTime was returning the time code when we pressed the Key, the only thing I had to do was to get
Time.time - startTime to get what I wanted. but it appeared that startTime always gave me a time code ~5 seconds bigger than Time.time. I’m trying to understand why, and how to get the right time code.
Hoping that I well explained my problem, this is my first time asking for something here.

Okay so since I don’t want to stay blocked on that problem for too long, I’ve temporarly fixed this by creating my own “startTime” variable :
float m_startTime = 0.0f;
float bool m_isRunning;
float bool m_prevRunning;

void Awake()
    m_playerInput = new PlayerInput();
    m_playerInput.Land.Run.performed += p_ctx =>
        // ReSharper disable once CompareOfFloatsByEqualityOperator
       m_isRunning = p_ctx.ReadValue<float>() == 1;

void Update()
    if (m_isRunning && !m_prevRunning)
        m_startTime = Time.time;

    m_prevRunning = m_isRunning;

Don’t forget to notify me when you have a better option or a more optimised code ^^

Just had the same problem. Found the solution in the documentation: Struct InputAction.CallbackContext | Input System | 1.0.2

Value relative to Time.realtimeSinceStartup when the action changed to started.

So now I just compare the startTime of the action against Time.realtimeSinceStartup instead of Time.time and it works perfectly :slight_smile: