com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Setting a NetworkAnimator boolean parameter to a value, then starting a Coroutine to set it back to the previous value next frame will cause the latest update to be overriden by the first change.

Open WhippetsAintDogs opened this issue 3 years ago • 1 comments

Description

Setting a NetworkAnimator boolean parameter to a value (e.g. false, was true before), then starting a Coroutine to set it back to the previous value (true) next frame will cause the latest update to be overriden by the first change.

Tl;dr NetworkAnimator doesn't handle well flickering parameter values.

Reproduce Steps

animator.SetBool("Parameter", false);
StartCoroutine(SetItBackNextFrame());

IEnumerator SetItBackNextFrame()
{
    yield return null;
    animator.SetBool("Parameter", true);
}

Actual Outcome

The animator's value is overriden to false after being true by the NetworkAnimator's UpdateParameters logic. false is the only thing that is replicated.

Expected Outcome

That the local value remains true afterward and that the replicated state is true.

Environment

  • OS: Windows 10
  • Unity Version: 2020.3
  • Netcode Version: develop (1.0.0)
  • Netcode Commit: 11922a0bc100a1615c541aa7298c47d253b74937

Additional Context

It seems that the next frame update in a Coroutine is evaluated before the NetworkUpdate (INetworkUpdateSystem). I don't know if we should change the timing of the NetworkAnimator or simply not UpdateParameters for the source of truth (the Owner).

For now, I've fixed it like that on my end: image

WhippetsAintDogs avatar Jul 29 '22 19:07 WhippetsAintDogs

Backlog MTT-4277

ashwinimurt avatar Aug 02 '22 20:08 ashwinimurt

@WhippetsAintDogs Hmmmm, yeah... that was something I was thinking about in the most recent update to NetworkAnimator which pretty much looks very similar to your fixes.

This updated version is available in the develop branch and will be available in the coming update.
Could you test your project against the develop branch and see if that resolves your issue? (if so I will associate this issue with that PR and close the issue out)

NoelStephensUnity avatar Oct 03 '22 15:10 NoelStephensUnity

@WhippetsAintDogs This issue should be resolved in v1.1.0.

NoelStephensUnity avatar Oct 31 '22 20:10 NoelStephensUnity