Sign in to follow this  
KillaChaos0

Handling Shooting

Recommended Posts

I am making a 2D side-scrolling shooter in python for educational purposes. I am just trying to implement the methods described in the Unreal engine as a guideline for future games. Currently I have it set so that each client does their own physics calculations, and sends data to the server every 50ms (The Source engine stated they were providing updates 20-30 times a second). Is this reasonable? Also I know in reality the server will do physics, and the client will "suggest" physics, but my server isn't a monster. Secondly, I have a simple reliable method (the sender sends a message and expects a 1 byte response, and if the response isn't received the sender will try again - up to 5 times). My question is, how should I handle things like bullets where the player may fire many bullets by clicking the mouse repeatedly be sent. I am currently thinking one click = one "reliable" call.

Share this post


Link to post
Share on other sites
First, think in messages, not network packets. Your client queues messages. 20 times a second, your client packs messages into a packet, and send one packet. Note that if you want to send _state_ of some object, you should enqueue "send state of this object," not the actual state; that way, the packet packer can grab the absolutely latest state at the point where it actually sends the packet.

Second, you probably need to allow multiple outstanding reliable messages. Else, with 400 ms ping between client and server (at least 10% of internet gamers have worse latency than this!), you could only send 2.5 such messages a second.

It's probably best to give each realiable message a sequence number. Then, pack all the reliable messages you have, in order, into each packet. When you acknowledge, acknowledge the latest message received in order. When you get the acknowledge, simply remove those messages from the queue. This way, reliable messages are always received in order, as quickly as possible -- at the cost of sending the messages a few times, thus using a little more bandwidth. As long as messages are smalled (and packed many to a packet), you should be fine.

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