Jump to content
  • Advertisement
texhnolyzze

Fighting Game Over Network

Recommended Posts

GGPO is described in a Gamasutra article  (that somewhat overpromises on how general it is): https://www.gamasutra.com/view/news/177508/The_lagfighting_techniques_behind_GGPOs_netcode.php

Global ordering between actors is somewhat possible, but I would say that it's always the "previous state" of an actor that affects the "next state" of another actor.

Thus, if A and B shoot each other on the same step, it doesn't matter who gets processed first. Both of the "previous" (alive) versions will "shoot" and generate "dead" targets in the next state. I e, the function is "stepWorld(oldState, newState)" where you area only allowed to read oldState, and only allowed to write newState. (And that will recursively hold for all entities in the world.)

If you keep copies of actor state for older time steps to implement lag compensated hitscan weapons, then this becomes pretty easy, because you "read" state at time step "stepFrom" and you "output" state at time step "stepTo."

Share this post


Link to post
Share on other sites
Advertisement

Also, regarding clock sync -- assuming latency is not too variable, you should be able to make the client send messages so they arrive at the server slightly before they're needed, which is really all you need.

You don't need to clocks to be 100% in sync, as long as the messages from the client arrive at the server within an acceptable window (say, between 1 and 4 simulation steps before they're needed -- your specific requirements may differ.)

 

Share this post


Link to post
Share on other sites
Posted (edited)

hplus0603

Okay, thank you for the answers.
Just the last question. Do you think I need to keep a snapshot buffer? Let’s say I received a batch of events from two players on the server, and say in the batch from player 1 there is an event “Punch”. This is a just an usual event, it has a timestamp (local timestamp of player 1). How do I handle this event on my server? Should I just apply it to the previous snapshot just like all the other events? Or should I apply this event in another snapshot, which is closest to the state of the game that player 1 saw while he pressed the "Punch" button. What if I detect the fist of player 1 in player 2? What should I do in this case? Thank.

Sorry for so many questions, I hope this is the last :)

Edited by texhnolyzze

Share this post


Link to post
Share on other sites

I would apply all events that affect some particular object, in the time step for that event.

If you have more than two players, you may end up with a situation where two players end up both dealing the "killing blow" in the same tick -- you're going to have to figure out what to do about cases like that.

Share this post


Link to post
Share on other sites
On 8/23/2019 at 10:34 AM, texhnolyzze said:

On this link:

Source-LagCompensation

There is such formula:

Command Execution Time = Current Server Time - Packet Latency - Client View Interpolation

Can you explain me please what is Client View Interpolation? Is this some constant tunable in Source Engine? I mean, if our server do 30 snapshots a second and sends them to clients, then Client View Interpolation will be 1000 / 30 = 33.333ms, cause client interpolates other players states within this interval, right?

I just figured this out myself.

Client view Interpolation is the amount of time the client has interpolated between 2 world states it has received.

Think of it as the client is running the game world in the past. It knows about 2 worldstates, and is waiting for a 3rd. It interpolates between the 2 worldstates while it waits for the 3rd otherwise players would "teleport" around visually. The server needs to know what 2 worldstates the player is interpolating between and *how far they've interpolated between them* in order to accurately recreate the state the player is seeing when they did the shoot command. Or at least, as close as possible of an estimate.

Hope that helps :)

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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!