Forcing Ownership to Scene for NPCs
Options
Hi,
I want to spawn a wave of enemies and give their photon view's ownership to Scene because I don't want the enemies be destroyed when the owner disconnects (currently the owner is always the master client). I am using PhotonNetwork.Instantiate to instantiate the enemies.
I see that photonView.owner is read only, so I don't know the right approach to do that or avoid the enemies be destroyed when master client disconnects.
Thanks so much.
I want to spawn a wave of enemies and give their photon view's ownership to Scene because I don't want the enemies be destroyed when the owner disconnects (currently the owner is always the master client). I am using PhotonNetwork.Instantiate to instantiate the enemies.
I see that photonView.owner is read only, so I don't know the right approach to do that or avoid the enemies be destroyed when master client disconnects.
Thanks so much.
0
Comments
-
Right now, there is no simple way to do this.
We read this request a few times though, so we're looking into this.
When a player leaves, who is going to control the player's items/units? Is it enough if they are just "around" or would you need to hand their control over to someone?
So far, when a player leaves, you could make the "master" replicate the objects that would vanish with the player. I don't know if that's feasible for your game but I think this is currently the only workaround.0 -
Does PUN work like unity in respect to the view ownership? with that I mean that when you allocate a new view id into the view.viewID does it transfer ownership to the one filling this new id?
Cause in unity owner is readonly too, due to the fact that it makes no sense to be able to set it if you down own the view id anyway0 -
Right now, we don't transfer the ownership. Not even if you re-assign a new viewID.
In the background, we use buffered events for instantiate requests. Those belong to an actor and are cleared when the player leaves a room. We can't (yet) keep the instantiated objects of players and we can't re-assign them (yet).
We're looking into this and would like to provide a solution soon.0 -
The leave situation makes it indeed more complex, especially with the master client. In Unity that can't cause any hickups cause server leaving = game is over0
-
When a player leaves, who is going to control the player's items/units? Is it enough if they are just "around" or would you need to hand their control over to someone?So far, when a player leaves, you could make the "master" replicate the objects that would vanish with the player. I don't know if that's feasible for your game but I think this is currently the only workaround.0
-
The new PhotonNetwork.InstantiateSceneObjects fixes your problems. These scene objects persist even if the current master client leaves (the new MC will take over control)0
-
This is really nice!! For the enemy-side it will work just fine since the master client, or the new host if master client leaves will take control fo the enemies AI. Great add to the package!0