How to send players input to server?

Options
Hello everyone,I am pretty new for unity and photon. I am making a Unity multiplayer game. Currently all the input is processed on the client, making the game vulnerable for cheaters and hackers. I switched to the self hosted thing(currently it is my computer). can someone please explain me how to process input on the server? Thanks a lot!

Best Answer

Answers

  • Hi @Ruslank,

    in order to run server-side custom logic, you have two possibilities. The first one is to use Plugins. Those Plugins can be used on a self-hosted server as well as on the Enterprise Cloud. Plugins allow injecting custom server-side logic into predefined hooks. You can read more about them here.

    The other option you have is to implement the entire server application on your own. This probably requires more work than implementing and using a plugin, but you would have full control about everything. To see how implementing your own server application works, you can take a look at the An App From Scratch documentation page.

    In general: both options are advanced topics. As a beginner I would start working with the Public Cloud first and focus on implementing the game. When the game is finished, you can still think about further steps you want to make: if the game becomes so successful that it attracts hackers, you can still start to do something against them.
  • Ruslank
    Options
    Interesting answer. I want to store a few sensitive variables, like health, on the server. And the same with shooting. I want that the server will instantiate a shell when I am clicking a left mouse button, and that the server will tell the player that he is damaged. Any idea how to? Or it is simplier to buy an anti cheat pack?
  • [Deleted User]
    edited October 2018
    Options
    The thing is, that you most likely won't have an Unity instance run on the server and furthermore don't instantiate a shell in terms of Unity's Instantiation. Instead you would have a simulation, which knows the position of each client and their input and must be aware of the map, too. Then you would do something like a Raycast to see if one client hits another client and update them accordingly.

    Something similar can be achieved, if you decide to use one client (i.e. the MasterClient) as authoritative client. This however might add noticeable lag to the game.
  • Ruslank
    Options
    it means, that master client(which will be the server), can store the variables of all clients?