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

Safely Simulating Player Movement Server-Side

5 posts in this topic

I have a fast paced multiplayer FPS game with the client running the player movement code and sending its position to the server. Obviously this is open to cheating so I want to have the player movement run on the server with the client sending only input to the server.

 

I have read all about client side prediction but there's still a few problems I'm not able to solve.

 

When I sample input and send that packet to the server, by the time the server receives it, the player simulation will have potentially moved the player to a different position than where the clients player was during that input.

 

One way to solve this is to send the frame time in the input packet to progress the simulation by that amount using that input. The problem with this is that it's also open to cheating, someone could speed up their client so the server simulates the player faster. I'm sure there's ways to detect that but there's still the problem of the player on the server freezing in mid-air when input isn't being received.

 

So to me it doesn't look like there's a perfect solution to this problem, I want the server to always simulate the player but due to packet latency, it's going to receive input at a different time than the client predicted it, resulting in constant error correction for the player.

 

An example of this is, imagine the client is predicting the player moving forward and then jumps, the server will be moving the player forward but the input with the jump keypress hasn't been received yet so the player on the server keeps running forward. When the input with the jump key press finally comes in, the player on the server has already ran into a hole but the client predicted that the player jumped over the hole.

Edited by laylay
0

Share this post


Link to post
Share on other sites
Yes, if the client has immediate user feedback, and the server runs the client based on inputs, then the client will be ahead of the server by the one-way latency between the two.

As long as the client and server run the same code, this is seldom a problem, except for the case where the client competes with another client -- who picks up a health pack first, client/client collisions, etc. Exactly how you solve those cases is an important part of how your game design and netcode arrive at the particular "feel" of your particular game.
0

Share this post


Link to post
Share on other sites

Even if it's running the same code, the server is using the last received input to drive the player. Without going back in time on the server, actions are going to happen at completely different times than what got predicted. I know that it's going to go out of sync if the server does something to the player that the client can't predict, I'm fine with that. I just can't fix this specific problem without causing some kind of cheating.

 

One way I thought about solving this is to timestamp the input packets and have the server go back in time to apply inputs and simulate the player from where they actually happened but only allow a small timeframe of about 200ms. That's still open to abuse but maybe there's no stopping that completely.

 

Perhaps it's better if I just send frametimes to server so it knows how long to simulate for but protect against huge frametimes that can't possibly happen, that way a cheater wont gain an advantage but could freeze the player in mid-air (which may not be an advantage depending on the game)

Edited by laylay
0

Share this post


Link to post
Share on other sites

actions are going to happen at completely different times than what got predicted. I know that it's going to go out of sync


I am assuming that you are fixing your time step, counting steps (not seconds,) and that you are running the client ahead of the server -- when the server is at step N, the client is already at step N+L, such that the client sent the data for step N, L steps ago.

Assuming that the client latency is predictable, the client can "cheat" by introducing additional fixed latency (up to some limit,) but that would also make the reverse problem -- extrapolation of other players -- a lot worse, so nobody would want to do that.

If you want a perfectly level playing field, fix the run-ahead latency of ALL the clients to the same number, and reject clients that can't keep up to that number.
0

Share this post


Link to post
Share on other sites


If you want a perfectly level playing field, fix the run-ahead latency of ALL the clients to the same number, and reject clients that can't keep up to that number.

 

Even then, some of the issues will still remain. If two players hit the health pack in the same update somebody gets it and somebody doesn't. In that case some other priority will take place, such as the lower-numbered player or the one that is first updated in the physics engine.

 


Perhaps it's better if I just send frametimes to server so it knows how long to simulate for but protect against huge frametimes that can't possibly happen, that way a cheater wont gain an advantage but could freeze the player in mid-air (which may not be an advantage depending on the game)

 

The details of the solution greatly impact the feel of the game. If you allow longer windows the game starts to feel more 'squishy', or less prone to things not being where they were expected.

 

For some games that can add to the fun and distinctive feel. I remember a lot of Quake exploits along these lines. One of the more annoying was how some players would literally climb the walls thanks to tiny errors that were only reachable on specific performance configurations, allowing them to unexpectedly cling near the ceiling and snipe everybody spider-man style.

 

You wrote you want an FPS, which means you will want more precision but it comes at the cost of requiring low latency and small timing windows.

 

There are many common tricks to make it feel better, such as playing a slightly longer animation for the triggering player, and a shorter animation on the receiving player, with the time difference being roughly the lag time. Even then, the more you push it the more players will complain. See the forum FAQ for links to a bunch of articles that describe other common ways to mask the lag.

0

Share this post


Link to post
Share on other sites

In that case some other priority will take place, such as the lower-numbered player or the one that is first updated in the physics engine.


Or coding this explicitly, and either use a deterministic random number generator, or actually detect this and resolve it as "neither player got it."
There are many solutions. Pick the ones that work for your desired gameplay style.
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