Skip to content

Commit 4cd5092

Browse files
fix: NetworkAnimator destinationStateMachine exception [MTT-5083] (#2309)
* fixes This fixes the issue where NetworkAnimator was not taking into consideration `AnimatorStateTtansition.destinationStateMachine`. Now, NetworkAnimator parses each destinationStateMachine's states for trigger transitions and includes those in the transition table. passing setTrigger bool to internal method. Fixed issue where the host client was receiving the ClientRpc animation updates when the host was the owner. Fixed an issue with using pooled objects and when specific properties are cleaned during despawn and destroy. This fixes the issue where NetworkAnimator was checking for animation changes when the associated NetworkObject was not spawned. * update Removed the AnimationSynchronizationData class as it really was not needed. Adding UNITY_INCLUDE_TESTS define in the components AssemblyInfo.cs file. This includes some updates to NetworkAnimator that will remove the need to synchronize client's using RPCs but instead use the new OnSynchronize method. * test manual Updated the NetworkAnimator manual test that provides a way to validate this fix visually. Minor fix for weapon attack option in manual test. * test Updating test to validate states defined within a destinationStateMachine are triggering. Made components visible to testproject again although I might try to figure out a better way to handle these two ways of testing. Updated the NetworkAnimatorTests to acquire the state info from NetworkAnimator.SynchronizationStateInfo. Co-authored-by: Unity Netcode CI <74025435+netcode-ci-service@users.noreply.github.com>
1 parent b007fbd commit 4cd5092

17 files changed

+1597
-355
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ Additional documentation and release notes are available at [Multiplayer Documen
2020
- Network prefabs are now stored in a ScriptableObject that can be shared between NetworkManagers, and have been exposed for public access. By default, a Default Prefabs List is created that contains all NetworkObject prefabs in the project, and new NetworkManagers will default to using that unless that option is turned off in the Netcode for GameObjects settings. Existing NetworkManagers will maintain their existing lists, which can be migrated to the new format via a button in their inspector. (#2322)
2121

2222
### Fixed
23+
- Fixed a UTP test that was failing when you install Unity Transport package 2.0.0 or newer. (#2347)
2324
- Fixed issue where `NetcodeSettingsProvider` would throw an exception in Unity 2020.3.x versions. (#2345)
2425
- Fixed server side issue where, depending upon component ordering, some NetworkBehaviour components might not have their OnNetworkDespawn method invoked if the client side disconnected. (#2323)
2526
- Fixed a case where data corruption could occur when using UnityTransport when reaching a certain level of send throughput. (#2332)
2627
- Fixed an issue in `UnityTransport` where an exception would be thrown if starting a Relay host/server on WebGL. This exception should only be thrown if using direct connections (where WebGL can't act as a host/server). (#2321)
27-
- Fixed a UTP test that was failing when you install Unity Transport package 2.0.0 or newer. (#2347)
28+
- Fixed `NetworkAnimator` issue where it was not checking for `AnimatorStateTtansition.destinationStateMachine` and any possible sub-states defined within it. (#2309)
29+
- Fixed `NetworkAnimator` issue where the host client was receiving the ClientRpc animation updates when the host was the owner.(#2309)
30+
- Fixed `NetworkAnimator` issue with using pooled objects and when specific properties are cleaned during despawn and destroy.(#2309)
31+
- Fixed issue where `NetworkAnimator` was checking for animation changes when the associated `NetworkObject` was not spawned.(#2309)
2832

2933
## [1.2.0] - 2022-11-21
3034

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
using System.Runtime.CompilerServices;
22

33
#if UNITY_EDITOR
4-
[assembly: InternalsVisibleTo("Unity.Netcode.EditorTests")]
54
[assembly: InternalsVisibleTo("Unity.Netcode.Editor.CodeGen")]
65
[assembly: InternalsVisibleTo("Unity.Netcode.Editor")]
6+
#endif
7+
8+
#if UNITY_INCLUDE_TESTS
9+
#if UNITY_EDITOR
10+
[assembly: InternalsVisibleTo("Unity.Netcode.EditorTests")]
711
[assembly: InternalsVisibleTo("TestProject.EditorTests")]
8-
[assembly: InternalsVisibleTo("TestProject.RuntimeTests")]
912
#endif
13+
[assembly: InternalsVisibleTo("TestProject.RuntimeTests")]
1014
[assembly: InternalsVisibleTo("Unity.Netcode.RuntimeTests")]
15+
#endif

com.unity.netcode.gameobjects/Components/NetworkAnimator.cs

Lines changed: 240 additions & 204 deletions
Large diffs are not rendered by default.

testproject/Assets/Tests/Manual/NetworkAnimatorTests/AnimatedCubeController.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,20 @@ private void DisplayTestIntValueIfChanged()
165165
m_TestIntValue = testIntValue;
166166
Debug.Log($"[{name}]TestInt value changed to = {m_TestIntValue}");
167167
}
168-
var testFloatValue = m_Animator.GetInteger("TestFloat");
168+
var testFloatValue = m_Animator.GetFloat("TestFloat");
169169
if (m_TestFloatValue != testFloatValue)
170170
{
171171
m_TestFloatValue = testFloatValue;
172172
Debug.Log($"[{name}]TestFloat value changed to = {m_TestIntValue}");
173173
}
174174
}
175175

176+
private void BeginAttack(int weaponType)
177+
{
178+
m_Animator.SetInteger("WeaponType", weaponType);
179+
m_NetworkAnimator.SetTrigger("Attack");
180+
}
181+
176182
private void LateUpdate()
177183
{
178184

@@ -212,6 +218,17 @@ private void LateUpdate()
212218
Debug.Log($"[{name}] TestInt value = {m_TestIntValue}");
213219
Debug.Log($"[{name}] TestInt value = {m_TestIntValue}");
214220
}
221+
222+
if (Input.GetKeyDown(KeyCode.Alpha1))
223+
{
224+
BeginAttack(1);
225+
}
226+
227+
if (Input.GetKeyDown(KeyCode.Alpha2))
228+
{
229+
BeginAttack(2);
230+
}
231+
215232
}
216233
}
217234
}

0 commit comments

Comments
 (0)