• 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
JacopoMTK

Client-Server network and physics collision

5 posts in this topic

Hi everyone,

 

I want to build a small client-server network for a spaceship game using TCP [to simplify things].

I'm kind of new on game network programming so i searched a bit on the web and it seems to me that

the easiest implementation is quake 3-like network algorithm.

 

note:a easy-to-program solution is preferable to one with high performance (within limits of course)

 

I was thinking to let the server manage the REAL state of the game and send information of it to the clients.

Meanwhile,clients only send "controller input data" for example

"client X has pressed button01" that mean he want to move forward etc.

"client X has pressed button02" that mean he want to fire primary weapon and so on.

 

Thinking about this,since it's my first experience in this kind of programming i've some question that come to mind:

-It should be safe since all the physics is managed on the server side.

-Sending input data without prediction on the client side and waiting for the server response for the new state

 could deliver a strong lag on player having high ping: if player X has 150ms of ping,when he press the move button

 he will actually start moving 300ms later [client-srv   //position computation//  srv- client]

-What's the best way to synchronize packets? I was thinking about sending a timestamp withing each packet

but,what will this time is referred to? I can't use local machine time since it could be different and...

will be a time synchronization (to a webserver for example) be reliable with some millisecond precision?

 

 

Can you guys please give me some opinions on those points?

Will the "send input to server" system hit so hard on performance?

 

Thanks in advance.

 

0

Share this post


Link to post
Share on other sites
As you've pointed out the problem with sending the inputs to the server is they take time for the server to process and return the result.

What you can do is send the key press to the server and then stimulate the key press immediately on the client. Then the server predicts the movement and possible future position of where it expects the player to be and sends the info back to the client which can use this data along with its current position data to work out its location.

I know you said for simplicity to keep it TCP but if packets are supposed to be sent often then id recommend using a UDP socket instead as TCP sends a message to the server which processes it then sends a confirmation message its been received. UDP just sends the message without waiting around for that confirmation back making it much quicker

Hope that helps with your problem
0

Share this post


Link to post
Share on other sites

I want to build a small client-server network for a spaceship game using TCP [to simplify things].

There are several topics:

1. tcp/udp

2. client prediction

3. lag hidding

 

1. starting with tcp isn't a bad idea, just remember, that tcp is a stream . The disadvantage is, that you will send every information in the right order through the tcp channel, even if the data are already obsoleted by newer data. Best to think already in packets/messages, even when using tcp, so that you can switch to udp or a tcp/udp hybrid more easily later on.

 

2. Client prediction helps to smooth fast paced action experiences. If you have e.g. a relative slow moving spaceship game, prediction might not be needed at all, therefor test it out without client prediction first.

 

3. Lag hidding is an other option. E.g. you can use delayed actions to hide the lag. Press the button to fire a missile, the fireing of the missile have a delay of 2 seconds, because the missile bay needs to be opened (a sound plays).  Even if the missile bay opening sound starts later and it is not exactly 2 seconds after pressing the button, that the missile starts, the player will most likely not recognise the lag. There are other options to hide it, e.g. a laser tower which needs to track the target etc. Sometimes starting the visual/audio effects when pressing the button (e.g. laser effect) is enough to hold up the illusion of a lag-less game experience.

0

Share this post


Link to post
Share on other sites

Thanks to both for the reply!smile.png

 

@bb_buster

So i start moving without waiting the server and eventually fix the position depending on the server response?

 

I had in mind to use UDP but i don't want to get a lot of problem due to data loss since,for what i know,they're pretty tricky to find.

Anyway it should be possible to switch to UDP by implementing an ack solution.

 

@Ashaman73

 

1. Sure,using packets is the idea.

2. The problem is that,those ships don't move slowly,i hope that it could be solved by using an high priority on the position check.

As you said,i'll test it out without prediction first.

3. Oh god...that's so simple as smart!I didn't thought about masking the lag in that way,thanks!

 

 

Oh another thing,what is a normal update time of the network?

I suppose to have to transfer data from the client to the server only when the user do something but what about

the other way?

Every how many update cycles should i transfer the data from server-->client to update other players position etc?

(having for example 60 update call per second)

 

Thanks again.

0

Share this post


Link to post
Share on other sites
A typical update rate on consoles is 15 times a second. This means data for 4 simulation ticks is included in each update. It also means you add up to 70 milliseconds of "artificial" lag compared to a 60 Hz network rate. You do save a lot of bandwidth, though, which is important for console certification.

High-performance Counter-Strike servers may run at 60 Hz or even 100 Hz network rate. It's unlikely that most games will find that to be a useful trade-off, though. More than 30 Hz for network packets is usually not warranted, and 20 Hz is often quite sufficient even for action games.
0

Share this post


Link to post
Share on other sites

Thanks for the detailed answer,i'll do some testing between 15-20 Hz

And thanks for pointing out the lag issue.

I don't know how much it effects the network state but it's good you pointed it out.

In the end that computational lag should be masked since every client will have the same 70ms offsett (plus the connection lag).

 

Thanks.

0

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