Skip to content

PlayerObjects don't clean up if the player connection is disconnected by the server #795

@dwoodruffsf

Description

@dwoodruffsf

Describe the bug
If you spawn a Player Object explicitly like this:
newPlayer.SpawnAsPlayerObject(clientId, null, true);

It will clean up if the player disconnects. But if the server force-ends the client connection via DisconnectClient, the object is left hanging around.

image
(state of NetworkObject after creation--note it is owned by "client 2" which is the connecting client).

To Reproduce
Steps to reproduce the behavior:

  1. In the BossRoom demo, comment out the netObj.Despawn(true) statement in ServerGameNetPortal.BootClient.
  2. In the BossRoom demo build a non-development client.
  3. Start one host and go all the way into game.
  4. Start two joiner clients and have them late-join to the host.
  5. Observe that the 2nd connection kicks the 1st connection (per our design in BossRoom not to let the same GUID connect twice), but that the 1st connection's character is still hanging around.

Actual outcome
Player object of severed client connection is left behind on host.

Expected outcome
Player object of severed client connection is cleaned up regardless of whether by client disconnect, or server calling DisconnectClient.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows 10
  • Unity Version: 2020.3.0f1
    MLAPI Version: 0.1.0
  • MLAPI Commit: tag release/0.1.0

Additional context
Add any other context about the problem here. Logs, code snippets would be useful here but please also consider attaching a minimal Unity project that reproduces the issue.

Metadata

Metadata

Assignees

Labels

good-first-issueContributions are welcome. Good first issue for newcomers or first time contributors.type: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