FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.39k stars 149 forks source link

OnSpawnServer & OnDespawnServer on players objects called twice and on the wrong objects #754

Closed stuw-u closed 3 months ago

stuw-u commented 3 months ago

General Unity version: 2022.3.37f1 (LTS) Fish-Networking version: 4.3.8R Discord link: https://discord.com/channels/424284635074134018/1272411047394934885

Description The NetworkBehaviour's "OnSpawnServer" is called twice AND "OnDespawnServer" is called once on a wrong object, and twice on the right object.

Replication Steps to reproduce the behavior: Set a NetworkObject with a NetworkBehaviour script that has OnSpawnServer and OnSpawnServer as the player. In both function, write a print statement that shows the method has been called, with the OwnerId to show which object gets the call.

  1. Start a host ("OnSpawnServer" is called twice for owner 0)
  2. Make a client join the server. ("OnSpawnServer" is called twice for owner 1)
  3. Make the client leave the server ("OnDespawnServer" is called once on the wrong object, and twice on the client)

Expected behavior OnSpawnServer is only ever called once, and is called on the right object.

Screenshots image image

stuw-u commented 3 months ago

I think I might've misunderstood how this method works.