Jump to content

General Multiplayer movement speed


Recommended Posts

I need some help with the concept of limiting movement speed for multiplayer games. 

Current this is my server code (Java)

case "2":

This receives the request for a player movement update and then sends the client the new movement coords.


This is the client code (GDScript)

func _input(event):
	#move up
	if Input.is_key_pressed(KEY_W):
	#move left
	elif Input.is_key_pressed(KEY_A):
	#move down
	elif Input.is_key_pressed(KEY_S):
	#move right
	elif Input.is_key_pressed(KEY_D):

This chunk of code sends the server the request for a movement change when a button is down, of course this sends the server this packet as fast as your fps.


I want to regulate speed on the server side. I cannot think of a way to accomplish this. 

Im not asking for exact code, just concepts. I want to be able to limit speed by an arbitrary value. 


Thank you for any help!

Link to comment
Share on other sites

You gotta regulate speed first on the client, and then use the server for corrections. The client and server should both know how fast the player can move from one tile to the other.


Outside of that input event you need to check and see if the player is already moving, if so don't send any packets.


The server needs to keep track of the last player movement time and if another movement packet comes in too fast send a position correction to the client. The goal is to find a happy medium where the server allows some timing variation due to potential latency and doesn't send corrections but for that variation to be small so speed hacking isn't an issue...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...