Skip to content

Commit d712ff8

Browse files
authored
Merge branch 'develop' into chore/bump-to-1.0.1
2 parents 08b13da + 08f6f99 commit d712ff8

File tree

46 files changed

+5175
-826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5175
-826
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Changelog
23

34
All notable changes to this project will be documented in this file.
@@ -17,16 +18,22 @@ Additional documentation and release notes are available at [Multiplayer Documen
1718

1819
### Fixed
1920

21+
- Fixed an issue where reading/writing more than 8 bits at a time with BitReader/BitWriter would write/read from the wrong place, returning and incorrect result. (#2130)
22+
- Fixed issue with the internal `NetworkTransformState.m_Bitset` flag not getting cleared upon the next tick advancement. (#2110)
23+
- Fixed interpolation issue with `NetworkTransform.Teleport`. (#2110)
24+
- Fixed issue where the authoritative side was interpolating its transform. (#2110)
25+
- Fixed Owner-written NetworkVariable infinitely write themselves (#2109)
26+
- Fixed NetworkList issue that showed when inserting at the very end of a NetworkList (#2099)
2027
- Fixed issue where a client owner of a `NetworkVariable` with both owner read and write permissions would not update the server side when changed. (#2097)
2128
- Fixed issue when attempting to spawn a parent `GameObject`, with `NetworkObject` component attached, that has one or more child `GameObject`s, that are inactive in the hierarchy, with `NetworkBehaviour` components it will no longer attempt to spawn the associated `NetworkBehaviour`(s) or invoke ownership changed notifications but will log a warning message. (#2096)
2229
- Fixed an issue where destroying a NetworkBehaviour would not deregister it from the parent NetworkObject, leading to exceptions when the parent was later destroyed. (#2091)
2330
- Fixed issue where `NetworkObject.NetworkHide` was despawning and destroying, as opposed to only despawning, in-scene placed `NetworkObject`s. (#2086)
31+
- Fixed `NetworkAnimator` synchronizing transitions twice due to it detecting the change in animation state once a transition is started by a trigger. (#2084)
2432
- Fixed issue where `NetworkAnimator` would not synchronize a looping animation for late joining clients if it was at the very end of its loop. (#2076)
2533
- Fixed issue where `NetworkAnimator` was not removing its subscription from `OnClientConnectedCallback` when despawned during the shutdown sequence. (#2074)
2634
- Fixed IsServer and IsClient being set to false before object despawn during the shutdown sequence. (#2074)
27-
- Fixed NetworkLists not populating on client. NetworkList now uses the most recent list as opposed to the list at the end of previous frame, when sending full updates to dynamically spawned NetworkObject. The difference in behaviour is required as scene management spawns those objects at a different time in the frame, relative to updates. (#2062)
2835
- Fixed NetworkList Value event on the server. PreviousValue is now set correctly when a new value is set through property setter. (#2067)
29-
- Fixed NetworkList issue that showed when inserting at the very end of a NetworkList (#2099)
36+
- Fixed NetworkLists not populating on client. NetworkList now uses the most recent list as opposed to the list at the end of previous frame, when sending full updates to dynamically spawned NetworkObject. The difference in behaviour is required as scene management spawns those objects at a different time in the frame, relative to updates. (#2062)
3037

3138
## [1.0.0] - 2022-06-27
3239

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

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public class NetworkAnimator : NetworkBehaviour
163163
internal struct AnimationMessage : INetworkSerializable
164164
{
165165
// state hash per layer. if non-zero, then Play() this animation, skipping transitions
166+
internal bool Transition;
166167
internal int StateHash;
167168
internal float NormalizedTime;
168169
internal int Layer;
@@ -427,6 +428,7 @@ internal void ServerSynchronizeNewPlayer(ulong playerId)
427428

428429
var animMsg = new AnimationMessage
429430
{
431+
Transition = m_Animator.IsInTransition(layer),
430432
StateHash = stateHash,
431433
NormalizedTime = normalizedTime,
432434
Layer = layer,
@@ -442,6 +444,9 @@ private void OnClientConnectedCallback(ulong playerId)
442444
m_NetworkAnimatorStateChangeHandler.SynchronizeClient(playerId);
443445
}
444446

447+
/// <summary>
448+
/// Checks for changes in both Animator parameters and state.
449+
/// </summary>
445450
internal void CheckForAnimatorChanges()
446451
{
447452
if (!IsOwner && !IsServerAuthoritative() || IsServerAuthoritative() && !IsServer)
@@ -482,6 +487,7 @@ internal void CheckForAnimatorChanges()
482487

483488
var animMsg = new AnimationMessage
484489
{
490+
Transition = m_Animator.IsInTransition(layer),
485491
StateHash = stateHash,
486492
NormalizedTime = normalizedTime,
487493
Layer = layer,
@@ -744,7 +750,13 @@ internal unsafe void UpdateParameters(ParametersUpdateMessage parametersUpdate)
744750
/// </summary>
745751
private unsafe void UpdateAnimationState(AnimationMessage animationState)
746752
{
747-
if (animationState.StateHash != 0)
753+
if (animationState.StateHash == 0)
754+
{
755+
return;
756+
}
757+
758+
var currentState = m_Animator.GetCurrentAnimatorStateInfo(animationState.Layer);
759+
if (currentState.fullPathHash != animationState.StateHash || m_Animator.IsInTransition(animationState.Layer) != animationState.Transition)
748760
{
749761
m_Animator.Play(animationState.StateHash, animationState.Layer, animationState.NormalizedTime);
750762
}
@@ -830,6 +842,10 @@ private unsafe void SendAnimStateServerRpc(AnimationMessage animSnapshot, Server
830842
[ClientRpc]
831843
private unsafe void SendAnimStateClientRpc(AnimationMessage animSnapshot, ClientRpcParams clientRpcParams = default)
832844
{
845+
if (IsServer)
846+
{
847+
return;
848+
}
833849
var isServerAuthoritative = IsServerAuthoritative();
834850
if (!isServerAuthoritative && !IsOwner || isServerAuthoritative)
835851
{
@@ -879,11 +895,7 @@ private void SendAnimTriggerServerRpc(AnimationTriggerMessage animationTriggerMe
879895
[ClientRpc]
880896
internal void SendAnimTriggerClientRpc(AnimationTriggerMessage animationTriggerMessage, ClientRpcParams clientRpcParams = default)
881897
{
882-
var isServerAuthoritative = IsServerAuthoritative();
883-
if (!isServerAuthoritative && !IsOwner || isServerAuthoritative)
884-
{
885-
m_Animator.SetBool(animationTriggerMessage.Hash, animationTriggerMessage.IsTriggerSet);
886-
}
898+
m_Animator.SetBool(animationTriggerMessage.Hash, animationTriggerMessage.IsTriggerSet);
887899
}
888900

889901
/// <summary>
@@ -900,8 +912,13 @@ public void SetTrigger(string triggerName)
900912
/// <param name="setTrigger">sets (true) or resets (false) the trigger. The default is to set it (true).</param>
901913
public void SetTrigger(int hash, bool setTrigger = true)
902914
{
903-
var isServerAuthoritative = IsServerAuthoritative();
904-
if (IsOwner && !isServerAuthoritative || IsServer && isServerAuthoritative)
915+
// MTT-3564:
916+
// After fixing the issue with trigger controlled Transitions being synchronized twice,
917+
// it exposed additional issues with this logic. Now, either the owner or the server can
918+
// update triggers. Since server-side RPCs are immediately invoked, for a host a trigger
919+
// will happen when SendAnimTriggerClientRpc is called. For a client owner, we call the
920+
// SendAnimTriggerServerRpc and then trigger locally when running in owner authority mode.
921+
if (IsOwner || IsServer)
905922
{
906923
var animTriggerMessage = new AnimationTriggerMessage() { Hash = hash, IsTriggerSet = setTrigger };
907924
if (IsServer)
@@ -911,9 +928,11 @@ public void SetTrigger(int hash, bool setTrigger = true)
911928
else
912929
{
913930
SendAnimTriggerServerRpc(animTriggerMessage);
931+
if (!IsServerAuthoritative())
932+
{
933+
m_Animator.SetTrigger(hash);
934+
}
914935
}
915-
// trigger the animation locally on the server...
916-
m_Animator.SetBool(hash, setTrigger);
917936
}
918937
}
919938

0 commit comments

Comments
 (0)