Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions com.unity.netcode.gameobjects/Components/NetworkAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ private unsafe void SendParametersUpdateServerRpc(ParametersUpdateMessage parame
return;
}
UpdateParameters(parametersUpdate);
if (NetworkManager.ConnectedClientsIds.Count - 2 > 0)
if (IsHost && NetworkManager.ConnectedClientsIds.Count > 2 || NetworkManager.ConnectedClientsIds.Count > 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see...yes that is a good catch indeed!
How about we condense that to something like:

                if (NetworkManager.ConnectedClientsIds.Count > (IsHost ? 2 : 1) )
                {

Thank you for your contribution and taking the time to troubleshoot that! 👍

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Can do, but isn't it more clear as it is?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well...with your current suggested fix you could still have a Host with one connected client and it would pass the conditional "If" check. My update to your suggestion assures that if it is a Host it requires more than 2 connected clients, otherwise if it is server it only requires one.
Does that make sense?

Copy link
Copy Markdown
Author

@florius0 florius0 Aug 15, 2022

Choose a reason for hiding this comment

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

Indeed, we overlooked it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done.

{
m_ClientSendList.Clear();
m_ClientSendList.AddRange(NetworkManager.ConnectedClientsIds);
Expand Down Expand Up @@ -812,7 +812,7 @@ private unsafe void SendAnimStateServerRpc(AnimationMessage animSnapshot, Server
return;
}
UpdateAnimationState(animSnapshot);
if (NetworkManager.ConnectedClientsIds.Count - 2 > 0)
if (IsHost && NetworkManager.ConnectedClientsIds.Count > 2 || NetworkManager.ConnectedClientsIds.Count > 1)
{
m_ClientSendList.Clear();
m_ClientSendList.AddRange(NetworkManager.ConnectedClientsIds);
Expand Down Expand Up @@ -857,7 +857,7 @@ private void SendAnimTriggerServerRpc(AnimationTriggerMessage animationTriggerMe
// trigger the animation locally on the server...
m_Animator.SetBool(animationTriggerMessage.Hash, animationTriggerMessage.IsTriggerSet);

if (NetworkManager.ConnectedClientsIds.Count - 2 > 0)
if (IsHost && NetworkManager.ConnectedClientsIds.Count > 2 || NetworkManager.ConnectedClientsIds.Count > 1)
{
m_ClientSendList.Clear();
m_ClientSendList.AddRange(NetworkManager.ConnectedClientsIds);
Expand Down