Player Input in Client/Server Games

Started by
2 comments, last by BoReDoM_Inc 18 years, 4 months ago
I'm interested to know how people manage control in a client/server based game where the Player is an entity existing in a scene on the server. eg. On the client there is a Input class that has a pointer to the Player on the server and the Input sends information telling the player to move. That's just a suggestion I would like to here how other people do it. Thanks
Advertisement
A lot of it depends on how secure you want the game to be. You can offload a lot of the processing for the entities (all the math for movement and physics) by having them processed on the client machines and then sending just the resultant data (animation frame, current position, etc.).
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
Not sure what you mean by "pointer" on the client machine. Storing an actual pointer (memory address) on the client to an object allocated on the server's heap for the game's process is useless. You can't use the pointer on the client machine and have changes be reflected on the server.

All your communication between client and server is going to be done through UDP or TCP. Your input class is going to need some way of communicating with a socket on the server. Your input will be read from the socket on the server, translated, and then submitted to your game for processing.

Example:
You press "up" on the client, the client generates a packet that says "the object that I'm in control of should now move forward", then sends the packet to the server, which reads the packet, translates it into something the game can use (such as a Command struct or object) and then eventually the game will process the Command and set the object's velocity accordingly.
Sorry I did not explain that although it is Client/Server based it is not the networking that is the problem. I mean my engine just has a Client/Server structure. The client is an exe that hooks into a .dll which is the server, I have not setup networking yet.
However I think I have had my question answered, Thanks.

This topic is closed to new replies.

Advertisement