简体   繁体   中英

Unity3D Speed Hack Detection

I want to know is there any way to detect our game against speed hack applications like game guardian?

I search all over internet but I didn't get a satisfying answer.

The solution is not more software on top. The solution is not being vulnerable to this from the start.

Example:

If you allow your users to send your server their coordinates on the world map ("I am the blue player and since I moved my full allowance, I'm now at 156/467"), it's trivial for somebody to write a teleport cheat. Just send different coordinates, boom teleported. Kids play.

If you only allow your users to send messages of intent to your server ("I am the blue player and I intend to move my full allowance in the direction of 156/467") and let your server figure out what that means (is the player allowed to move, what is his allowance, how far will the blue player get in one unit of time) and send the result back, you will never have that problem.

Do not trust client input. First rule of video game security: The client is in the hands of the enemy.

There is little point in shoving more and more software on top of your client if you keep trusting your client. Just stop and design your game so the client can send intent and the server determines outcome.

It depends on your game, but you can try detecting speed hacks by simply checking player position every frame.

  1. Determine maximum possible move distance per second and put it in constant, so that the player wouldn't be able to change that at runtime.
  2. Cache current position.
  3. On next update, check the distance the player travelled and multiply it by the Time.deltaTime .
  4. If the player travelled more than maximum allowed, the player must have cheated.
  5. Return to step no. 2

It will be framerate independent checking as you will be using maximum allowed distance per second .

If the server has all player positions at all time and your problem is with speed hacking the solution is not that hard (assuming player position is being sent to server constantly).

Please do the following, first before updating player position check if the distance between current position and old position isn't too big

  var distance = Vector3.Distance(old.position, currentposition);
if(distance<=alloweddistance)
...

and if it is avoid updating position\\set player to old position\\kick player. A better solution to even that, is to not allow players to send their current position to server, rather send direction they are moving and speed. The server should change their position with the direction and move speed, not client.

I found Solution for my own project that is online multiplayer and it works for any online game.

For solving this problem just we need to calculate time in server. for example we can use stopwatch and doing this in client side... and in an specific situation we can compare them over network and if there was any difference between them, (some thing like more than 3 second) then becomes clear that player is used speed hack.

I tried this method in my game and it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM