Sign in to follow this  
BoReDoM_Inc

Player Input in Client/Server Games

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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

Sign in to follow this