Hello,
I noticed a funny behavior with item pickups in the PUN integration. What is happening is when items are dropped onto the ground, and then they are picked up, the client who picks them up deletes them from their game scene. But the other clients in the lobby only set the pickup to disabled, and do not delete them.
Is this a purposeful behavior that when one client deletes a picked up item, the other clients only disable it? The disabling is occuring through the DestroyInternal of PunObjectPool, which does ObjectPool.Destroy(). This disables the GameObject, which triggers the PunLocationMonitors to send a SetActiveRPC call to the other clients. If this is purposeful, why wouldn't we want the other clients to delete the GameObject, instead of just disabling it?
The draw back of this behavior is demonstrated by this workflow:
A non-master client picks up a dropped item, the master client is only told to disable the picked up item (not delete it). This causes the master client to not perform DestroyInternal of PunObjectPool, and the m_ActiveGameObjects dictionary does not remove the pun pickup item from its entries. When a new client connects, the master client then performs PunObjectPool.OnPlayerEnteredRoom which checks the m_ActiveGameObjects to raise the object instantiation event. Since the pun pickup item still exists in that dictionary, it gets recreated and placed back into the world for the other clients.
What would be the recommended solution here?
I noticed a funny behavior with item pickups in the PUN integration. What is happening is when items are dropped onto the ground, and then they are picked up, the client who picks them up deletes them from their game scene. But the other clients in the lobby only set the pickup to disabled, and do not delete them.
Is this a purposeful behavior that when one client deletes a picked up item, the other clients only disable it? The disabling is occuring through the DestroyInternal of PunObjectPool, which does ObjectPool.Destroy(). This disables the GameObject, which triggers the PunLocationMonitors to send a SetActiveRPC call to the other clients. If this is purposeful, why wouldn't we want the other clients to delete the GameObject, instead of just disabling it?
The draw back of this behavior is demonstrated by this workflow:
A non-master client picks up a dropped item, the master client is only told to disable the picked up item (not delete it). This causes the master client to not perform DestroyInternal of PunObjectPool, and the m_ActiveGameObjects dictionary does not remove the pun pickup item from its entries. When a new client connects, the master client then performs PunObjectPool.OnPlayerEnteredRoom which checks the m_ActiveGameObjects to raise the object instantiation event. Since the pun pickup item still exists in that dictionary, it gets recreated and placed back into the world for the other clients.
What would be the recommended solution here?