Hot answers tagged

10

Problem analysis Real-time communication over a high-latency connection is obviously impossible. You can of course attempt an illusion (as you're doing by making the remote player appear to have passed an obstacle when it's not yet known). When that illusion fails (as yours does when the remote player didn't actually pass the obstacle, but died instead) ...


6

Any drawing API function called from the CPU will be submitted to the GPU command ring buffer to be executed later by the GPU. This means that OpenGL functions are mostly non-blocking functions. So the CPU and the GPU will be working in parallel. The most important thing to note is that your application can be CPU or GPU bound. once you call glFinish the ...


5

The easiest solution to the "who did it first?" problem is an authoritative server. Both players connect to the server which handles all the game mechanics. Whatever arrives first at the server is considered as happening first. So if the server receives a message "I place a wall" from player B and then a millisecond later a message "I move to where the ...


4

You can safely throw out Ping from the board. Lag compensating can work relying on just number of ticks for which commands were received (including NoCommand commands) and confirmed. Since the game is p2p (via server or not it does not matter), each client has number of packets from other clients queued for execution and confirmations of packets he sent. ...


4

To complement Anko's answer, you can change a bit your game design by adding the consequence of the failed obstacle after the failure, for instance, a failed jump results in landing in a puddle of mud which disqualifies the player. This way the other player notices the failure by seeing the other fall in the mud, while the player who fails sees it right away....


4

OpenGL never updates the screen, technically. There is a window system API that is separate from GL (e.g. GLX, WGL, CGL, EGL) that does this. Buffer swaps using these APIs generally implicitly invoke glFlush (...) but in some implementations (e.g. the GDI rasterizer on Windows) it does a full glFinish (...):       *On the left ...


3

That's an interesting problem, I handle my SDL events like this, while (SDL_PollEvent(&e) != 0) { // handle events here } This will handle all the SDL events in the queue, and if their aren't any events in the queue it just ignores trying to handle the events in the queue. P.S. at the end of each iteration of my game loop (The handle user input, ...


2

The general gist is that you have two concepts of "state". Local state (your client) Ghost state (the server) You take input from your client, and update your local client state (and send this to the server). You then "predict" what happens to everyone else, assuming some amount of spatial consistency to last frame. When you get information from the ...


2

I have an idea of where the jittering comes from with vSync and triple buffering. The easiest way to show this is visually. The first example would be 30fps with a 60hz refresh rate vSynced with Double buffering. The pipes are new frames and periods are duplicated frames. |.|.|.|.|.|.|.|.|. This gives an even ~33ms between each new frame, which makes it ...


2

With a multiplayer >2 game like StarCraft you can do a best out of X to figure out who's lagging. With a 2 player game there is no way to know who's at fault as it's a single connection, its that one connection that is having issue. Again, there is no such thing as player B being disconnected as the one single connection gets broken, both A and B gets ...


2

I highly recommend you study the TCP model; it is very mature and has many features built in over the years, making it a jack-of-all-trades networking protocol. It will likely have features that address any follow-up concerns you may have. The scenario you describe is also known as packet loss; Player_A has sent a confirmation to Player_B but Player_B hasn'...


2

I actually wanted to add this as a comment, but since I need reputation to comment... A long time ago, back in Unity 4, I tried using the Network Emulation and got this feeling that my prototype was handling lag and packet losses very nicely. Then I discovered that there are unclear circumstances in which the Network Emulation adds to nothing - in fact, ...


2

After much research and readings I think I can answer my own question. This is not really a solvable problem. All clients are seeing other client’s commands x time from the past, and there are no solutions to synchronize real time behavior if one client intends to directly affect another player without corrections. The best thing you can do is do your best ...


2

First of all, I commend you for thinking outside the box. Keep doing that. Here are a couple problems off the top of my head with one potential implementation. (Only a partial answer.) It increases latency for all players, including the already highest ping player. How much pseudo ping do we add? We must first check which player has the highest ping. ...


1

The JS engine of the web browser operates in a single thread and has a task queue which operates on the first-come-first-served principle. That means anytime an event occurs, that event is pushed to the end of the task queue and gets acted upon as soon as everything that happened before was executed completely. requestAnimationFrame tells the web browser to ...


1

I timed the Godot example (see below) and got the timings below both for curl and godot. Using the debug profiler I did not found any long running thread(s). You could use a process trace tool like dtrace (MacOS) or strace (linux) to find the culprit. curl time curl https://httpbin.org/get { "args": {}, "headers": { "Accept": "*/*", "Host": ...


1

The time it takes to pack and unpack the data is likely negligible. But there is a different problem: Compression works best when you have a lot of data to compress. So if you want compression to be effective, you might end up withholding data until you have enough of it that it is worth compressing. This is at odds with the goal of reaching low latency. ...


1

TL;DR: Will compression hurt? No. But it probably won't help you if your goal is a very responsive game. You have two problems to solve with connectivity... Can I get enough data to the client in time? In other words, is my bandwidth enough? Is the "pipe" I have to send data big enough to carry the data? If you can't send enough data in time, then ...


1

As Steve Smith pointed out in the comment above: "the player will always send the correct info about Command Execution Time" - Are you sure? Could be a mechanic for cheating if the player could say "I was actually elsewhere when the bullet supposedly hit me". Let's say I'm a player interested in exploiting your system. If I know your server trusts the ...


1

The client is currently at Tick=115, but the server is at Tick=130, but why?! Why is the client behind? Because the client has to wait until it has information from the server in order to process it. So in this case you can assume that the client has a ping of 15ms because that is the difference between the two. The client can't process past tick 115 ...


1

A simple solution i found, is to keep track of how many server ticks have gone without processing input from the client. This amount is then decremented for each subsequently processed input. This allows for multiple inputs to be processed at each server-tick, but no more than the tick-rate. Im still open for other ideas, but for now, this is what i'll ...


1

First, you need to assure that you get your commands to be more stable than "highly unlikely." Why is 'pause' state ignoring remote updates? Second, often quoted networking reference contains examples of handling latency on both server and client, plus dependable communications. I think that ideas on that page may make you rethink your "turn n+1" concept ...


1

No. You have a condition in CheckCollision() that only prints 'Inner' if the condition is true (the condition is that there has to be at least one Platform that is in the proper state to apply the code block to. So for several Update calls, the code flow went to CheckCollision() but there were no Platforms colliding (probably) so there was zero items to run ...


1

Explain multiplayer game. In fps games, 100 milliseconds can change the outcome of your shots. In civizilation-type games, you can have up to 1000 milliseconds without even noticing it, and up to 2000, without being seriously frustrated. In games, where everyone does his thing, like in simcity 5 (let's assume simcity 5 is one of them, and it doesn't kicks ...


1

Your intuition about #1 is correct: don't trust client timestamps. Even without cheating, timestamps can be wildly wrong. Best approach is to ping, and divide the ping time by two. The lag may be asymmetric, but there's no way to verify that from the server. If you already have a persistent connection (TCP), that channel is fine. For just a ping, a no-setup ...


1

It's been a while but I thought I'd answer for posterity. The algorithm is simply: Each player sends his commands to all other players every turn. (If they have nothing to order in particular, the message could just say "I have 0 commands for turn X".) Each player waits for all other players' commands before executing the current turn. So in the described ...


1

Lockstep Networking is simple in theory but hard in practice. I've implemented lockstep networked fight systems for AAA online games and I have a few recommendations. The most important thing is player comfort. If you do an attack, you must play some kind of action on the local player immediately (ie. The next frame). This can be a swing anim, or an effect, ...


1

I assume you're familiar with this experiment? Essentially John Carmack was doing something similar, recording the screen and timing pixels sent to the screen. He found that a good deal of the latency came from the screen. Other factors were the input delay from the keyboard, video drivers and or course the execution of the program itself.


Only top voted, non community-wiki answers of a minimum length are eligible