how to make master client destroy other's players objects?

Options
Hello everyone, I am making a multiplayer game, and I made authoritive shooting with master client(regular clients cant create rooms, so they cant be master clients). When a shell hits a player, it damages the player. I am trying to Network - Destroy the hitplayer, if it has less HP than 0. But of course, it raises an error, because masterclient doesnt own the hitplayer. Any idea how to workaround this?

Answers

  • Hi @Ruslank,

    you can try using PhotonNetwork.DestroyPlayerObjects(int targetPlayerId) if this fits into your game logic. DestroyPlayerObjects can be used by the MasterClient to destroy all GameObjects, PhotonViews and their RPCs of the target player.

    If you can't use this call, you have two other options. The first would be to ask the Owner of the object, to destroy it. This can be done by using a RPC for example which is only send to the Owner of the object. The other option would be to request and transfer the Ownership of the object to the MasterClient and let him destroy this object on his own. Both options might add noticeable lag to the game.