How can I best control AI entities in my game and stop cheating?

Hello!

My game (You can view the trailer here, as it may help you to view my problem in a better light) has got a lot of NPCs.

Not only are there AI tanks in this tank game, but there are also AI turrets as well.

Now my problem is simple: I don't want a single "master client" controlling everything. I am planning to have 20 players per room at least, and this means that having a single client control every piece of AI would be stupid. What if the client is lagging? What if the client disconnects?

The other problem with having a single "Master client" control the room is cheating. Now, I know that I could get all other players to check for cheating from the master client, but what are they going to do then? There seems to be no way to kick the master client or be able to prevent cheats at all.

Also, can't the "Master client" spawn stuff into the world? How can I prevent the master client from just creating a bunch of fake tanks and trolling the entire world?

Needless to say, I need a way of stopping cheating in my game. I need a way for all the clients to agree on something, and if a client is in disagreement, it is kicked.

My game is currently running with PUN. If this isn't possible with PUN, what would be the best alternative, that would require the least code changes?

To be honest, I'm a bit lost: There seems no clear way to prevent cheating or ensure stability or agreement with clients in my game, thanks to (as far as I can see) the poor system of PUN.

In short:

I want my game to run smoothly without any interruptions (e.g. if a master client lags).

I want my game to run without cheaters.

I want my game's clients to agree with each other, for example about bullets hitting a target.


How can I achieve all my 3 objectives? Is it even possible with PUN? If it isn't possible with PUN, what is a system that I could switch to that would require minimal changes to my code?

Best Answer

Answers

  • Hi @Joehot200,

    I want my game to run smoothly without any interruptions (e.g. if a master client lags).


    Neither you or us have influences on the clients network connection, means that you can't get fully rid of interruptions. In terms of AI, the best approach when using the Cloud might be, to spread the load to either multiple or all users, so that each client is responsible for a certain amount of AI elements. This is different, when you have the possibility to use server-side logic, which is possible on the Enterprise Cloud by using Plugins or by hosting the Photon Server yourself and either create the entire Server Application on your own or using a Plugin again. By using server-side logic, those AI objects can be handled on the server as well.

    I want my game to run without cheaters.


    Short answer: impossible.

    Long answer: you have different possibilities to make it harder for cheaters to sabotage your game. When using the Cloud you can use the MasterClient and let him accept or refuse anything that happens in the game. This works mostly fine as long as the MasterClient is not a cheater himself. In terms of removing a cheater from the game: this is possible since PUN version 1.89, which introduced the CloseConnection feature. Another option you have is to use an authentication provider. Using one you can at least ban certain users from the game. When you have the possibility to use server-side logic, you can do way more to prevent cheating in your game, for example check certain actions by users (for example hit detection or movement).

    I want my game's clients to agree with each other, for example about bullets hitting a target.


    You can do this by using custom events and messages for example by using the RaiseEvent function. The problem is, that this adds some (noticeable) lag to the game which might have a bad influence in terms of player experience.
  • Joehot200Joehot200
    edited July 3

    Hi @Joehot200,

    I want my game to run without cheaters.


    Short answer: impossible.

    Long answer: you have different possibilities to make it harder for cheaters to sabotage your game. When using the Cloud you can use the MasterClient and let him accept or refuse anything that happens in the game. This works mostly fine as long as the MasterClient is not a cheater himself. In terms of removing a cheater from the game: this is possible since PUN version 1.89, which introduced the CloseConnection feature.
    Hi @Christian_Simon

    Thank you very much for your answer.

    The main problem I have with CloseConnection() is that as far as I'm aware, it is only possible for the master client to kick other players? Surely other players can't call CloseConnection() on the master client.

    What I really need is a way for the majority of other clients to vote between themselves that the master client should be kicked, and then kick him. That would solve my cheating problem.

    Additionally, I need to make sure that the master client cannot just randomly kick other players.
Sign In or Register to comment.