• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
simpler

Network game design question

6 posts in this topic

I just recently started working on my next project which will be multiplayer exclusively with support for up to 8 players. It's really important that the clients are synced since avoiding projectiles and having good micro will be a key part in the game.

I got some questions regarding the networking architecture on a game like this. I'm going to use RakNet and I'm pretty sure I will use a client-server approach. I got two different methods I'm considiring

[b]Method 1[/b][list]
[*]The only task the server has is to inform all clients when a client does something. The server don't have any World class, it just forwards the events to the client and let them update their own World.
[*]A client right clicks on the map to add a target to move to. The client then sends a package to the server containing the event id, client id and the target position. The server then [i]only[/i] sends the package to all connected clients and let them handle it.
[/list]
The bandwidth usage will be very low since packages only gets sent on user input. I do however think that the clients very easily will get out of sync, and there's nothing that will make them synced again.

[b]Method 2[/b][list]
[*]The server contains a World class that gets updated when clients perform actions. This World then gets broadcasted to all clients frequently (how often?) and the clients then set the objects positions so they are the same as the servers.
[*]A client right clicks on the map to add a target to move to. It sends the event to the server who then updates it's World. The server does nothing more in this stage, the changes will get broadcasted to all clients in X ms.
[/list]
I'm not sure how often this broadcast will happen but it will definitly be more bandwidth heavy than method 1. This method does however make sure that the clients are synced.

This is just what I came up with after 1 day of researching and I would love if you could share things I should think about and general suggestion. [i]How would you do something like this?[/i] Edited by simpler
0

Share this post


Link to post
Share on other sites
Method 1 is easily hackable, so I would stick to method 2.

The tick rate depends on the game type, mostly they go from 20 ticks per second to 60 ticks per second. Some servers (I read LoL is this way somewhere, can't say if the font is reliable) tick as fast as they can. My network experiments (mostly RPG based) ticked 20 times per second with good results.

If you are worried about latency, take a look at "client side prediction".
1

Share this post


Link to post
Share on other sites
Thanks for the great answer KnolanCross! When ticking 20 times per second, I guess you are interpolating the positon updates to make it smooth?

I did some searching for "client side prediction" and it's exactly what I will need to use. I found [url="http://web.cs.wpi.edu/~claypool/courses/4513-B03/papers/games/bernier.pdf"]this[/url] article and it seems really interesting :)
0

Share this post


Link to post
Share on other sites
[quote name='simpler' timestamp='1353532325' post='5003021']
Thanks for the great answer KnolanCross! When ticking 20 times per second, I guess you are interpolating the positon updates to make it smooth?

[/quote]

Not really, mostly you don't send coordinates, you send a message telling that someone is moving then the server spreads the message to the other clients.
So each client interpolates the movement by themselves.
From time to time the server may send a message with each player's coordinates so the client can fix the error.
1

Share this post


Link to post
Share on other sites
I see. Is it correct to say that it's a combination of method 1 and 2? Something like this:

1.) A client presses a key and an event is sent to the server. The server handles the event in it's own World class and the event is then broadcasted to all other clients. The other clients handles the event as well and updates their World.
2.) At a fixed time step the server broadcasts it World to all clients. If a position of an object on a client differs from the server by a certain value that position gets set to the servers.

Is it the step 2 that you sent 20 times per second?
0

Share this post


Link to post
Share on other sites
[quote name='simpler' timestamp='1353535511' post='5003038']
I see. Is it correct to say that it's a combination of method 1 and 2?
[/quote]

Not really, the main point here is that the server is the one who decides who is right (unlike method 1 you described in your first post). The clients' view of the world will be near the reality, but very unlikely to be 100% precise.
This is very easy to spot in some games. If you have ever played arena in World of Warcraft you probably have been hit by some enemy skill when you were behind a pilar. This happens because in your screen you are behind a pillar, but in the server (the real simulation) you are not, and the server is the one who decides who is right.

[quote name='simpler' timestamp='1353535511' post='5003038']
Something like this:


1.) A client presses a key and an event is sent to the server. The server handles the event in it's own World class and the event is then broadcasted to all other clients. The other clients handles the event as well and updates their World.
2.) At a fixed time step the server broadcasts it World to all clients. If a position of an object on a client differs from the server by a certain value that position gets set to the servers.
[/quote]
Yes, those two steps describes what should happen. It is important to notice that the client should start moving right away (even before the server has actually answered it).

[quote name='simpler' timestamp='1353535511' post='5003038']
Is it the step 2 that you sent 20 times per second?
[/quote]

Yes, just make sure this 20 times per second is configurable, you game may require more or less than that.
1

Share this post


Link to post
Share on other sites
[quote name='KnolanCross' timestamp='1353519595' post='5002958']
Method 1 is easily hackable, so I would stick to method 2.

The tick rate depends on the game type, mostly they go from 20 ticks per second to 60 ticks per second. Some servers (I read LoL is this way somewhere, can't say if the font is reliable) tick as fast as they can. My network experiments (mostly RPG based) ticked 20 times per second with good results.

If you are worried about latency, take a look at "client side prediction".
[/quote]

If you use method 1 you should run a local simulation on the server to determine the actual result of the game. (You could of course also get the results from the clients and only replay the game, based on the inputs, if there are inconsistencies) And of course determinism in the simulation is important.

In my opinion broadcasting the inputs is totally valid. Of course with this approach each client knows the whole game state at any moment, thus it is possible to do map hacks etc. . In League of Legends, for example, method 2 is used and you only get updates for players you actually see, so is is impossible to use map hacks. I heard fight games like Street Fighter sometimes use an input based network system where they also predict the game state by using the local inputs, but maybe someone else can elaborate a bit more on that subject.

Also if you have a game where dodging projectiles is important I am not sure if client side prediction is a good thing. I guess it is better to use some other mechanic (http://www.gamasutra.com/view/news/177508/The_lagfighting_techniques_behind_GGPOs_netcode.php#.UK9xFeOe9h4) to hide the delay, and show all game objects in the same point in time.

edit: Let me correct on this. Client side prediction together with interpolation for other game objects is probably a bad idea if the relative position of the player to the other objects is important. That is, you could either display everything in the past or if you want high responsiveness you predict not only the local player but the whole game state.

So in short, if it is not important to hide some information from the clients (i.e. you have no fog of war etc.) you could definitely go for method 1, which can give you very good results for a fast paced action game. Edited by Inferiarum
1

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  
Followers 0