I’m looking for the best way to handle game logic for a two player battle game. (This is for both unet and photon as I’m still learning and haven’t picked one over the other yet). In the single player version I have player game objects to handle player input. Then the game manager object handles all the damage math and showing the hud. For two player I was going to use the same set up but the host would create the GM at the start so both players would have access to it. Problem is the more I read about this I’m finding this is easy to cheat with.
I guess I could use a server but I don’t even know we’re to start with that. I want to try and learn from this so i don’t need a direct answer, but a point in the right direction would be great.
First start with p2p model, where each player calculates its own logic and tells the others what he has done. This type of networking however, makes cheating extremely easy as each client can edit its own values in logic.
The other way is client to server model, also known as authoritative , players only send inputs to a server that does the logic for all players and then broadcasts the results , this way no cheating can be done, since you the player only watch the result of your own inputs and never really do any important logic locally.
P2p was the way I was going. I was working with pun and had a basic network working. But like you said, the more I read the cheating issue kept popping up. Started looking in to using a server but felt a bit lost. I was reading the doc about unet and came across a part saying the host is runs the server and a local client. Wasn’t sure if it was authoritative or not.
Just get Photon Server, it works the same exact way as PUN Starting out, and gives you full authority to do what you’d like.
Not to mention, P2P isn’t that bad, it’s not hard to irritate a cheater if you know how to call things right.
E.G. a bullet. Make the bullet on your end a fake bullet, looks exactly the same, does nothing at all but move forward. However, make the real bullet instantiate on the other clients end, if they somehow make the bullet damage stronger, guess what, it’s going to kill them instead in 1 shot instead of 10. or whatever it is they want to do.