Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpawnObjects sends spawn messages to Connections that do not have Player objects #3540

Open
James-Frowen opened this issue Jul 3, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@James-Frowen
Copy link
Contributor

Describe the bug
when manually loading scene the order of functions causes clients to be unable to spawn scene objects.

NetworkServer.SpawnObjects() only checks IsReady, so will send spawn messages to all ready connections
NetworkServer.SetClientReady() checks if there is player object before spawning.

if SpawnObjects is called on server after client is ready, but before player objects are added then Client wont find scene objects.

This makes scene loading difficult in host mode because SpawnObjects must be called on host before NetworkClient.Ready is called

How can we reproduce the issue, step by step:

  • Load new scene
  • Call NetworkClient.Ready() on clients
  • when all players are ready call NetworkServer.SpawnObjects() on server
  • See that server sends Spawn message NetworkConnections that have Identity == null
  • See errors on clients Spawn scene object not found for

Expected behavior

  • Server should not add NetworkConnections that as observer or send Spawn messages when conn.Identity is null

Version
Mirror version: v78.3.0

Suggested fix
NetworkServer.AddAllReadyServerConnectionsToObservers should also check conn.identity != null before adding Observers

@MrGadget1024 MrGadget1024 added the bug Something isn't working label Jul 4, 2023
@James-Frowen
Copy link
Contributor Author

workaround for client, call PrepareToSpawnSceneObjects() before Ready()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants