Ownership of AI for co-op

Options
I'm working on co-op mode for my game. I've taken the route of having the AI (enemy objects) as full PhotonView entities. The MasterClient is in charge of spawning (NetworkInstantiating) and controlling the AI (using IsMasterClient in Update). This is all working perfectly.

However, once the Master Client leaves the game, all of the AI entities are destroyed along with his player entity. Obviously this is expected behaviour, but I was hoping to be able to do one of the following when the Master Client leaves:

1. Transfer ownership of the AI PhotonViews to the new Master Client or
2. Orphan the AI PhotonViews so that they can be picked up by the new MasterClient the next time they are updated

In either case, I don't know if it's possible to stop the AI entities from being destroyed when the Mater Client leaves. Is it possible to intercept destruction, or set something on the photonview so they are not destroyed?

Thanks

Comments

  • vadim
    Options
    Use PhotonNetwork.InstantiateSceneObject on master client. Such objects should survive master change.
  • GarethIW
    Options
    Thanks, I'll give it a shot. Is that the difference between the two instantiations in the Boxes demo? You just reminded me of that one - I should have checked it out first!

    Awesome service + tools, by the way. Looking forward to purchasing a plan in the near future.
  • vadim
    Options
    You are right. 'OnClickInstantiate' script assigned to board spawns boxes with 2 different methods depending on 'InstantiateType' property value.

    It's very nice to hear that you like the service, btw.
  • GarethIW
    Options
    Tried this last night and it worked perfectly, thank you!

    jarh-ai.gif