Skip to content

OnNetworkDespawn not being called for client objects #2489

@Tristan559

Description

@Tristan559

Description

When a player joins my host game, and that player exits the session, OnNetworkDespawn() will not be called on the host for that player.

Reproduce Steps

  1. Have a simple network game that spawns players
  2. Have player join a host game in progress
  3. Have that player exit the game
  4. Notice that OnNetworkDespawn for that player is not called on the host's machine

Actual Outcome

OnNetworkDespawn() will be called for the host player when the game exists, but if a client joins and exits the game, OnNetworkDespawn() will not be called on the host for that client player.

Expected Outcome

When a client leaves the game, OnNetworkDespawn() is called on the player object on the host.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

  • OS: Windows 10
  • Unity Version: 2021.3.22f1
  • Netcode Version: 1.2.0
  • Netcode Commit: N/A

Additional Context

Players are spawned automatically via Network Manager. They are added to the list of Network prefabs in the editor. On the host, OnNetworkDespawn() is being called for the host's player when the host game exits. It isn't being called on the host when players from other clients leave the host's session.

A current workaround is to override OnDestroy() instead.

Metadata

Metadata

Labels

priority:mediumThis issue has medium priority and may take some time to be resolvedstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions