Skip to content

Conversation

@fernando-cortez
Copy link
Contributor

@fernando-cortez fernando-cortez commented Sep 20, 2023

Description

PR to address stuck ingredients when clients disconnect. The drop and pickup RPCs have been refactored, and a new class to handle NetworkObject parent changes has been added to Ingredient prefabs.

How to test

  1. Have one instance host
  2. Have another join host
  3. Make client pick up an ingredient and afterwards disconnect
  4. Ensure that the ball drops to the ground

Issue Number(s)

MTT-7103

Contribution checklist

  • [ N/A ] Tests have been added for the project and/or any internal package
  • Release notes have been added to the project changelog file
  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • JIRA ticket ID is in the PR title or at least one commit message
  • Include the ticket ID number within the body message of the PR to create a hyperlink

@fernando-cortez fernando-cortez added the enhancement New feature or request label Sep 20, 2023
@fernando-cortez fernando-cortez requested a review from a team September 20, 2023 19:57
Copy link
Contributor

@LPLafontaineB LPLafontaineB left a comment

Choose a reason for hiding this comment

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

Solution works, however we still get this warning:

[Netcode] NetworkObject #33 moved to the root because its parent NetworkObject #43 is destroyed
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.NetworkSpawnManager:OnDespawnObject (Unity.Netcode.NetworkObject,bool) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:843)
Unity.Netcode.NetworkSpawnManager:DespawnObject (Unity.Netcode.NetworkObject,bool) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:667)
Unity.Netcode.NetworkConnectionManager:OnClientDisconnectFromServer (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:780)
Unity.Netcode.NetworkConnectionManager:DisconnectEventHandler (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:369)
Unity.Netcode.NetworkConnectionManager:HandleNetworkEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1<byte>,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:264) Unity.Netcode.NetworkTransport:InvokeOnTransportEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/NetworkTransport.cs:49)
Unity.Netcode.Transports.UTP.UnityTransport:ProcessEvent () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/UTP/UnityTransport.cs:883)
Unity.Netcode.Transports.UTP.UnityTransport:Update () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/UTP/UnityTransport.cs:925)

Maybe deparenting the ingredient in the player character's OnNetworkDespawn would avoid this warning?

@fernando-cortez
Copy link
Contributor Author

Solution works, however we still get this warning:

[Netcode] NetworkObject #33 moved to the root because its parent NetworkObject #43 is destroyed
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.NetworkSpawnManager:OnDespawnObject (Unity.Netcode.NetworkObject,bool) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:843)
Unity.Netcode.NetworkSpawnManager:DespawnObject (Unity.Netcode.NetworkObject,bool) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:667)
Unity.Netcode.NetworkConnectionManager:OnClientDisconnectFromServer (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:780)
Unity.Netcode.NetworkConnectionManager:DisconnectEventHandler (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:369)
Unity.Netcode.NetworkConnectionManager:HandleNetworkEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1<byte>,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:264) Unity.Netcode.NetworkTransport:InvokeOnTransportEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/NetworkTransport.cs:49)
Unity.Netcode.Transports.UTP.UnityTransport:ProcessEvent () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/UTP/UnityTransport.cs:883)
Unity.Netcode.Transports.UTP.UnityTransport:Update () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/UTP/UnityTransport.cs:925)

Maybe deparenting the ingredient in the player character's OnNetworkDespawn would avoid this warning?

That's a good idea. Though I just tried this and the player's OnNetworkDespawn actually comes after this warning. It seems the warning is fired as the object is being despawned, so it's not possible to catch it.

@LPLafontaineB
Copy link
Contributor

Solution works, however we still get this warning:

[Netcode] NetworkObject #33 moved to the root because its parent NetworkObject #43 is destroyed
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.NetworkSpawnManager:OnDespawnObject (Unity.Netcode.NetworkObject,bool) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:843)
Unity.Netcode.NetworkSpawnManager:DespawnObject (Unity.Netcode.NetworkObject,bool) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:667)
Unity.Netcode.NetworkConnectionManager:OnClientDisconnectFromServer (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:780)
Unity.Netcode.NetworkConnectionManager:DisconnectEventHandler (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:369)
Unity.Netcode.NetworkConnectionManager:HandleNetworkEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1<byte>,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:264) Unity.Netcode.NetworkTransport:InvokeOnTransportEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/NetworkTransport.cs:49)
Unity.Netcode.Transports.UTP.UnityTransport:ProcessEvent () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/UTP/UnityTransport.cs:883)
Unity.Netcode.Transports.UTP.UnityTransport:Update () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Transports/UTP/UnityTransport.cs:925)

Maybe deparenting the ingredient in the player character's OnNetworkDespawn would avoid this warning?

That's a good idea. Though I just tried this and the player's OnNetworkDespawn actually comes after this warning. It seems the warning is fired as the object is being despawned, so it's not possible to catch it.

hmm looking at the logs it seems like OnClientDisconnect might happen before this warning, so we could use that to avoid the warning? But it doesn't seem like a clean solution anyways, maybe we should keep it this way with the warning instead

@fernando-cortez fernando-cortez merged commit 823f008 into develop Sep 22, 2023
@fernando-cortez fernando-cortez deleted the fix/client-driven-ball-stuck-on-disconnects branch September 22, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants