0
\$\begingroup\$

I'm using photon pun. I have a spawner script which instantiates the eatables in the gameplay and right after the instantiation, im transferring its ownership to null. The instantiated game objects's photon view component's ownership transfer variable is set to takeover.

But, my instantiated game object is still getting destroyed with the master client, how do i stop this from happening? Also I don't have any IPunOwnershipCallbacks in the instantiated game object script.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ From the example of pun By default, all GameObjects created by one player will be destroyed when he/she leaves. Are you using local multiplayer? Because when the server is the master client, you have a different problem if that one is disconnecting. Did you create the GameObjects with InstantiateSceneObject()? Or try setting PhotonNetwork.autoCleanUpPlayerObjects to false. But with no more code from you, we can only guess \$\endgroup\$
    – Zibelas
    Oct 20 at 11:52
  • \$\begingroup\$ @Zibelas Thank you for the comment. I did find a post mentioning the PhotonNetwork.autoCleanUpPlayerObjects. Although this was missing for me. Then I stumbled upon this post and it finally worked for me! \$\endgroup\$ Oct 20 at 12:03

1 Answer 1

0
\$\begingroup\$

I happened to have solved it. In the create room options, I set the variable CleanupCacheOnLeave to false. Now the game objects weren't getting destroyed when the master left and the ownership under the photon view component, I left it to fixed.

I found this post which got it working for me

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .