InputAxis.TriggerRecentering doesn't animate

In Cinemachine 3.1.0, the InputAxis.TriggerRecentering() function causes the axis to immediately snap to its recenter value, rather than animating the recentering over time.

It looks like there’s a bug in the “InputAxis.UpdateRecentering” function:

if (m_RecenteringState.m_ForceRecenter || (Recentering.Enabled && deltaTime < 0))
{
    Value = Center;
    CancelRecentering();
}
else if (m_RecenteringState.m_ForceRecenter
    || (Recentering.Enabled && RecenteringState.CurrentTime
        - m_RecenteringState.m_LastValueChangeTime >= Recentering.Wait))
{
    // animate the recentering...
}

That first if-clause is entered when m_ForceRecenter is true, which means the else if clause will never be entered for m_ForceRecenter (despite that clause explicitly checking m_ForceRecenter).

It looks like the parens in that first if-clause are probably not correct, and the condition should be written as:

if ((m_RecenteringState.m_ForceRecenter || Recentering.Enabled) && deltaTime < 0)

You are absolutely right! Thanks for that. Fixing for 3.1.1.

Hey!
Just friendly reminder - bug is still actual in 3.1.1, code wasn’t changed in mentioned place.

No, I just checked. It’s fixed. Are you sure you’re looking at the right version?

I’m afraid I’m facing the same situation as the previous user.
If it may help, on Cinemachine 3.1.1 I’m calling

HorizontalAxis.TriggerRecentering()

on the Orbital Follow component while the Recentering Target is “Tracking Target”.
Replacing the line of code with

HorizontalAxis.Recentering.Enabled = true;

works as expected instead. Making believe it’s just that specific function call that is not working.

If you’re calling TriggerRecentering() but recentering isn’t enabled, nothing will happen. This is expected. TriggerRecentering() doesn’t auto-enable recentering.

Thank you, understood now.
I was trying to use it with the goal of centering the camera forward - once, not continuously - during gameplay at the press of a button.
I see it can work this way if I enable recentering and set the wait time to an impossibly high value, but I gather that was not an intended case scenario.

For anyone else struggling with Cinemachine recentering, this information appears to be out of date (as of version 3.1.4). InputAxis.TriggerRecentering does in fact work regardless of if auto-recentering is enabled in the inspector, which makes sense because there’s plenty of situations you’d want to recenter (like on a button press) without a recenter being triggered on a delay.

However I was still seeing a problem where this TriggerRecentering call would be ignored for a short time after input. After digging into the code it turns out that any change in an InputAxis’s Value will force cancel any recentering, so even if you’ve stopped pressing your Look input on an InputAxisController it will continue to ignore TriggerRecentering until the Decel Time is finished. You can solve that by either setting Decel Time to 0 or by manually disabling the InputAxisController for a bit when you recenter.

I can understand why the automatic recentering should wait until after the Decel Time to start, but I will say I expected TriggerRecentering (whose description is “Trigger re-centering immediately, regardless of whether re-centering is enabled or the wait time has elapsed”) to work without those extra hacks, or at least to trigger after the Decel Time instead of just ignoring the call.