Stopping non-master clients from sending Instantiations?

Options
Hey everyone,

I've just started tinkering with pun at the beginning of the week and I've ran into some issues when trying to make the master client "authoritative".

As far as I'm aware, if I instantiate objects on the master client, the master client will have full control of that object and others will not be able to manipulate it.

Non-master clients however still have the ability to Instantiate any objects they like, as many times as they like and broadcast that to the rest of the room and I can't find a way to restrict that.

Is there a way that I can restrict clients from being able to do that? I would ideally like to be able to Instantiate the game objects on the master client and then transfer ownership of a "user controller" to each client that connects.

Comments

  • Hi @AzuraSky,

    the only way to prevent clients from instantiating objects is to not let them call any kind of Instantiation function. To do so you can for example surround each Instantiation call with a PhotonNetwork.isMasterClient condition. This way only the MasterClient will be able to network instantiate objects.

    To achieve what you want to have, clients can use the RaiseEvent function to send a 'request' to the MasterClient who then instantiates the object and transfers the Ownership to the requesting client. To learn more about Ownership Transfer you can take a look at this page if you haven't done this already.
  • AzuraSky
    AzuraSky
    edited November 2017
    Options
    Doesn't that mean though that somebody with a hacked client or someone sending fake packets is still able to instantiate objects for everyone else in the games scene?

    If this is the case, does that mean that authoritative games aren't possible within the photon engine?
    What are common anti-cheat mechanisms that are used with Photon?

    Also, how can I ensure that users who haven't bought the game aren't able to connect to my servers?
  • Doesn't that mean though that somebody with a hacked client or someone sending fake packets is still able to instantiate objects for everyone else in the games scene?


    Basically yes.

    If this is the case, does that mean that authoritative games aren't possible within the photon engine?


    They are possible. When using the Photon Server you can implement your own server-side logic. When using the Cloud things getting a bit more different because you need one client you trust. This client can be the MasterClient for example, who can also be not trustful. So this have some disadvantages as well. You might want to have a look at this discussion about the same topic, to see if this helps.

    Also, how can I ensure that users who haven't bought the game aren't able to connect to my servers?


    The best way might be to use Custom Authentication with a database of valid clients with user name and password, at least in my opinion. Without authentication anyone with the game client (legal or not) can login to the game.