Jump to content
  • Advertisement
Sign in to follow this  
Hayer

Multiplayer networking newbie

This topic is 2805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

here is how I do it atm;

When the client presses the move-left-key it sends a byte to the server. The server then updates the position of the client and 1 / 30 sec it sends a update with the position to all the players.

I can now see that this wont work over the inet - as im only testing locally atm. So how does the pro's do this?

Im using Lidgren by the way..

Share this post


Link to post
Share on other sites
Advertisement
First, what you do could work, although it may have a bit of lag.

Second, try the Forum FAQ, and especially the "zen of networked character physics" article by gaffer.

Share this post


Link to post
Share on other sites
What kind of player count are you planing on handling? That kind of send player actions + lag compensation is typical of FPS games with 16 to 32 players.

Share this post


Link to post
Share on other sites
Well, its a pretty simple game in logic-game code..

There is a team of 1-8 players on a map against some 8-10 different types of zombies.
And there will be a max of I guess 40-100 zombies.

The zombie limit is only limited by the net code - so I want some good net-code but I also want to keep it simple. So I guess I need to balance it between quality / simplicity.

Share this post


Link to post
Share on other sites
You can have 10,000 zombies with close to zero impact on netcode. You do this by spawning the zombies according to known locations, and then simulating them using deterministic simulation on each machine separately. Because computers can be deterministic (assuming you have no bugs), they will simulate the same value on all machines.

Read the "1,500 archers" article about Age of Empires, linked from the Forum FAQ.

Share this post


Link to post
Share on other sites
well, then pathfinding can't do anything "randomly" - so it seems kinda hard to make a smart AI?

Share this post


Link to post
Share on other sites
You can use randomly generated numbers too, you just have to be careful not to let the pseudo-random state get out of sync. The Age of Empires game had some random movement in it, e.g. grazing animals. IIRC one of the bugs they had (from that article) was traced back to these animals not behaving deterministically, leading to a subtle but increasing divergence of state between peers.

Share this post


Link to post
Share on other sites
You will want to look up Dead Reckoning. Basically, once you push left, you can assume that the left key is still being pushed until the client says that the key has been released.

By making such assumptions you can make the same calculations on the server. Further, you can simulate the same on all other clients as this is as much as they know.

Hope that helps you consider some different approaches.

Share this post


Link to post
Share on other sites
The problem is that there is so many ways to do it!
I only want a simple way that still gives a good result compared to how hard/long time it takes me.

Okey; atm im testing this:

1. The user sends a byte when *he presses a key
2. the server starts moving the object and keeps moving it until it gets a "kill-button"-byte
3. the user lets go of the button and sends the "kill-button"-byte

As you see the server still does all the moving - so how would I add some prediction to this?
And does prediction have some math-formulas? I can't seem to find them.. Or maybe its just me that needs to skill up my google'r-brain

Share this post


Link to post
Share on other sites
I am a newbie too but here is my 5 cents: you should always checking the ping time for all clients the server and keep them in a list.
Prediction comes right here, when server gets a button-press byte it assumes player has already gone pingtime*playerspeed and 'teleports' the player a little bit before making it move.
And same goes for clients if client gets a move-byte of another client it assumes player has already gone (mypingtime+hispingtime)*hisspeed and 'teleports' .
You can ofcourse have better approaches like sliding instead of teleporting.
I am currently trying to do some online zombie game too :). I'll just copy paste the ai code from server to clients and let them predict but once they get an update packet from server they will obey. And ill let clients delete bullets for example on collusion but i wont let them to decide damage or kill anything, at least in the beta.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!