MirrorNetworking / Mirror

#1 Open Source Unity Networking Library
https://mirror-networking.com
MIT License
5.25k stars 775 forks source link

Syncvar referencing a Pooled Network Behaviour cannot be set to null #3936

Closed joshcamas closed 3 weeks ago

joshcamas commented 3 weeks ago

Describe the bug When a network object has a syncvar that is a reference to a component that is also pooled (and the pooled network object was originally owned by another client), it can cause the syncvar to permanently not be modifiable.

[IMPORTANT] How can we reproduce the issue, step by step:

1) Have a network behaviour hold a syncvar that is referencing another network behaviour 2) Connect two players and have both behaviours owned by player A 3) Pool all of these objects 4) Pull one object out of the pool and assign to player B 5) Result: the synced reference syncvar will be permanently broken. It still holds a reference to a currently pooled object, but since it has an id of 0, it fails to get cleared no matter what. The value was also unable to be set due to on despawn the object was owned by player A.

Expected behavior As a owner, setting a SyncVar that is a reference to a currently non networked object should set that syncvar to null successfully.

Desktop (please complete the following information):

joshcamas commented 3 weeks ago

Cannot get a simple repro working, we'll just sync netids and not sync behaviours directly.