Hi,
i search an solution to prevent people from cheating in my game.
If i put a NetworkTransform on my player Prefab and the player has local authority, than its not a authoritative movement, because he is able to set his own transform (teleport for example)
Is there a build in solution, or should i do it by myself?
Should i move the player localy and send my inputs to the server, move it there and send the position?
(I use a rigidbody for my player, it should be a car game)
Well, this is client authoritative movement with server side sanity checks (teleports, etc.), which is not really what people generally consider authoritative movement. Not to say this is bad - most games are client authoritative to some degree, including movement. Generally I would suggest using client authoritative movement with sanity checks as described above. Focusing on solving a hard problem that may never manifest (because you don’t finish your game or the game doesn’t sell) lacks ROI. In the incredibly remote chance that you release a game that is very popular, it is a good (and solvable or at least mitigatable) problem to have.
Unet doesn’t support client side prediction with server authority natively (what is classically referenced here Server In-game Protocol Design and Optimization - Valve Developer Community), where the agents are simulated deterministically on both the client and server via an input / reset state mechanism.
Finally, since you are using a rigid body for your player, solving this truly authoritatively with the url I pasted is not really possible in Unity without a ton of work (and likely replacing the physics engine).
I should also note you have a third option - you can pass inputs to the server, and have the server process them and simulate the movement but you do not actually predict them on the client. Instead, the client’s agent is a proxy and is updated from the server. This is a server controlled entity and lacks client prediction, which means you will need to wait for a server round trip before you see the results of your movement. However, it would be server authoritative. This will have significant, connection dependent input lag and likely will feel very poor to the user, especially as agent movement speeds increase and precise handling becomes more important in order to avoid collisions.
1 Like
Should you feel like having a go at implementing what @DirtyHippy described, there’s a thread here that’s been going on awhile about client-side prediction.
As stated above, I wouldn’t bother with it until you’re sure that you will need it (i.e., your game is popular enough people will cheat). Ideally adding it in later in development should be relatively painless, as it’s just an extra couple step in the movement phase (where you send inputs to the server and then reconcile them on the client with the server’s position).
However, it is a really good exercise to learn the ins and outs of networking and Unet in particular…lots of little configurations can cause problems in the process so it forces you to really learn!