PhotonNetwork.Instantiate destroying instantiated objects when owner leaves

2.4k Views Asked by At

I am instantiating prefabs using PhotoNetwork.Instantiate. The problem is when the player who instantiated the objects leaves or disconnects the objects are destroyed for other players as well. Is there anyway to fix this ? I can use Remote procedure calls but my first priority is somehow fix this. I am new to photon pun but so far I've learned a lot. Any help will be appreciated. PS. the master client is network instantiating.

2

There are 2 best solutions below

0
On BEST ANSWER

This is the default behaviour by design, read here or here.

You can change it by setting RoomOptions.CleanupCacheOnLeave to false when creating rooms. You will have to do the manual clean up later by using PhotonNetwork.Destroy methods.

0
On

I solved the problem by instantiating the object as a room object instead of a network instantiate. That way when a player leaves the room the objects he instantiated arent destroyed.