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.

Comments

  • Tobias
    Options
    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.
  • dreamora
    Options
    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 anyway
  • Tobias
    Options
    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.
  • dreamora
    Options
    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 over ;)
  • tutibueno
    Options
    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?
    They are being controller by the master client. If they are around and owned by Scene it is perfectly fine as this just happens if you have all enemies being part of the level and not instantiated by anyone. But when I have to spawn a new enemy it never gets Scene as the owner, it always gets the master client as the owner regardless what the photon view of that particular enemy spawn point shows up (which is owned by scene).
    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.
    Yeah, I think this is a good solution, I'll try to do that and will let you know. But the bottom line is that it would be perfect if the owner of a instantiated prefab (located in Resources) be optionally the Scene itself so it would be independent of any player.
  • Leepo
    Options
    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)
  • tutibueno
    Options
    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!