Skip to content

feat: network animator Trigger parameter support #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 6, 2021

Conversation

pdeschain
Copy link
Contributor

@pdeschain pdeschain commented Jun 1, 2021

Epic Link: https://jira.unity3d.com/browse/MTT-586

Added functionality:

  • Trigger parameters can now be correctly synced via NetworkAnimators

Improvements:

  • Removed boxing and replaced animator data storage with strongly typed containers

Fixes:
https://jira.unity3d.com/browse/MTT-715 - we are no longer syncing parameters that are driven by animation curves. These parameters are being indirectly set when we sync layer state, so no reason to sync these.

I have also removed the ability to pick parameters of the animator that are being synced - all of them are synced now.

In order to implement the logic that can capture the value of Animator Trigger parameters we have to poll for these values on every frame - Trigger values are transient and can be consumed by the Mecanim internals at any update after they are set to True, thus making it impossible for us to actually detect them being flipped on. Thus we poll for Trigger changes in FixedUpdate - this point in Unity update loop currently seems to be the best time to check for Triggers regardless of the update type the Animator is using.

In order to check the value of a Trigger we rely on an undocumented feature of Animator.GetBool that will retrieve the value of the Trigger as though it was a bool (which it actually is, just with an added semantic of being immediately reset to False).

Initially an attempt was made to avoid syncing parameters at all and to just sync the Animator layer state, but it turned out to be insufficient to make the Animator on the other side to correctly replicate the visuals - Animator parameters are being re-evaluated by the update loop of Mecanim state machine, which happens every frame - and if the parameters aren't in sync, then certain undesirable transitions could be happening, thus breaking the animations on the non-auth peers' side.

In order to play with the new animator:

  • Build and launch
  • navigate to the ManualTests->NetworkAnimator
    Do the same in Editor (or start Play mode from Assets/Tests/Manual/NetworkAnimatorTests/NetworkAnimatorEnhancement.unity scene).

pdeschain and others added 11 commits May 19, 2021 16:34
… than before, supports Triggers but currently does not rely on netvars
…eird - we can't wait on serializing data till the tick end, this way we will most likely loose some of the netvar values which is potentially bad for trigger-based animations
…ty that's driven by animator curves

There is no reason to sync these parameter values - they are being indirectly updated via the layer state sync.
@0xFA11
Copy link
Contributor

0xFA11 commented Jun 7, 2021

just an early heads-up, I was planning to remove Unity-Chan! entirely from the testproject. medium/big assets make Yamato spend more time in tests due to importing and I think both for testing and the sake of package being smaller, we need to use primitives and small assets when it's absolutely required (I know, I put that in and made that mistake in the first place but will correct my mistake).
we can chat about this later, just wanted to plug it in here too.

@pdeschain
Copy link
Contributor Author

@MFatihMAR Aye-aye. I will replace UnityChan usage with something more lightweight after we're done with the draft review stage.

Copy link
Contributor

@LukeStampfli LukeStampfli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the improvements to NetworkAnimator are great and we should merge them for now to improve the animator which already exists and solve some of our user needs.

I don't think we are there yet with the NetworkAnimatorVar. I'm not convinced about including parameters in the animator state and the overall approach in general. I think this part needs some more exploration and potentially a bigger effort for creating a next generation network animator.

@pdeschain pdeschain marked this pull request as ready for review June 30, 2021 16:41
@pdeschain pdeschain requested review from LukeStampfli and removed request for 0xFA11, LukeStampfli, SamuelBellomo and NoelStephensUnity June 30, 2021 16:41
Copy link
Contributor

@LukeStampfli LukeStampfli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! NetworkAnimator looks much more clean now than before.

{
[CustomEditor(typeof(NetworkAnimator), true)]
[CanEditMultipleObjects]
public class NetworkAnimatorEditor : Editor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there anything replacing this or do you think default inspector UI (Editor) is good enough now?

{
if (IsOwner)
{
if(Input.GetKeyDown(KeyCode.C))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might consider running ./standards.py --fix once to format all source files :)

Suggested change
if(Input.GetKeyDown(KeyCode.C))
if (Input.GetKeyDown(KeyCode.C))

Copy link
Contributor

@0xFA11 0xFA11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks like a good refactor to me!
I left some minor comments & questions here and there.

one more thing though, would you also remove Unity-Chan! stuff in this PR as it was mainly there for testing/showing NetworkAnimator working but now we have simple cube anims replacing it?

@pdeschain pdeschain merged commit be0ca06 into develop Jul 6, 2021
@pdeschain pdeschain deleted the feature/network-animator-triggers branch July 6, 2021 19:12
SamuelBellomo added a commit that referenced this pull request Jul 8, 2021
…ity-Technologies/com.unity.multiplayer.mlapi into test/multiprocess-tests/orchestration

* 'test/multiprocess-tests/orchestration' of github.com:Unity-Technologies/com.unity.multiplayer.mlapi:
  Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
  rename test scene
  changing root menu
  no longer ignore '[Ss]treamingAssets/buildInfo.txt'
  feat: network animator Trigger parameter support (#872)

# Conflicts:
#	testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
SamuelBellomo added a commit that referenced this pull request Jul 8, 2021
…rocess-tests/base-multiprocess-tests

* test/multiprocess-tests/orchestration:
  Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
  rename test scene
  #
  changing root menu
  PR suggestions
  no longer ignore '[Ss]treamingAssets/buildInfo.txt'
  feat: network animator Trigger parameter support (#872)

# Conflicts:
#	testproject/ProjectSettings/EditorBuildSettings.asset
SamuelBellomo added a commit that referenced this pull request Jul 8, 2021
…est/multiprocess-tests/execute-step-in-context

* test/multiprocess-tests/base-multiprocess-tests:
  proper rename for scene
  rename for test scene
  Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
  rename test scene
  #
  changing root menu
  PR suggestions
  no longer ignore '[Ss]treamingAssets/buildInfo.txt'
  feat: network animator Trigger parameter support (#872)
SamuelBellomo added a commit that referenced this pull request Jul 8, 2021
…est/multiprocess-tests/adding-perf-tests-for-spawn

* test/multiprocess-tests/execute-step-in-context:
  proper rename for scene
  rename for test scene
  Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
  rename test scene
  #
  changing root menu
  PR suggestions
  no longer ignore '[Ss]treamingAssets/buildInfo.txt'
  feat: network animator Trigger parameter support (#872)

# Conflicts:
#	testproject/Assets/Tests/Runtime/MultiprocessRuntime.meta
#	testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers.meta
#	testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
SamuelBellomo added a commit that referenced this pull request Jul 8, 2021
…to test/multiprocess-tests/adding-doc-on-how-to-use

* test/multiprocess-tests/adding-perf-tests-for-spawn:
  proper rename for scene
  rename for test scene
  Update testproject/Assets/Tests/Runtime/MultiprocessRuntime/Helpers/BuildMultiprocessTestPlayer.cs
  rename test scene
  #
  changing root menu
  PR suggestions
  no longer ignore '[Ss]treamingAssets/buildInfo.txt'
  feat: network animator Trigger parameter support (#872)
SamuelBellomo added a commit that referenced this pull request Jul 23, 2021
…nsform

* develop:
  test: Perf tests part 3. Adding ExecuteStepInContext for better test readability (#924)
  test: Perf tests part 2. Adding Test Coordinator and base test class (#923)
  fix: (MLAPI.Serialization) 'specified cast is not valid.' on NetworkW… (#951)
  test: Perf tests part 1. Basis for multiprocess tests process orchestration.  (#922)
  feat: network animator Trigger parameter support (#872)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants