Jump to content

  • Log In with Google      Sign In   
  • Create Account


Apply Lag Compensation on non-instant events


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 Firnael   Members   -  Reputation: 182

Like
0Likes
Like

Posted 07 March 2013 - 04:06 AM

Hi,

 

I was reading this nice article for the 3rd time (after I read this blog entries 4 times). I got pretty much all of my questions answered but I miss something to get the global idea.

 

When you use Lag Compensation on instant events (like a gun shot in Counter Strike, bullet instantly teleport this its final location AKA a player or terrain if you missed), it's easy for the server to get the time when the event was fired, and rollback the entities positions in the past to perform the collision test.

Now when you deal with slower but yet precise collision detection over the network, like a skillshot in a MOBA (ex. a fireball with no particular target, go straight forward until it vanishes or hit some enemy), how do you handle proper lag compensation ?

 

Since the projectile has to travel and not teleport, you test collisions every game update, and if you do want to apply lag compensation, you have to rollback all entities (at least the near ones) every update.

 

Is that relevent ? I've always wondered how games like LoL ou DotA could feel this smooth.

I'm asking you this because I'm pretty sure dead reckoning and entity interpolation is near to unusable on situation like this kind of fast-paced games, you can't predict what the players will do next.

 

Thanks


Edited by Firnael, 07 March 2013 - 04:07 AM.


Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 6691

Like
1Likes
Like

Posted 07 March 2013 - 05:00 AM

I'm pretty sure dead reckoning and entity interpolation is near to unusable on situation like this kind of fast-paced games, you can't predict what the players will do next.

Well, dead reckoning and entity interpolation are for really fast action games like CC or CoD, Dota etc. are much slower. The trick in Dota etc., which are more RTS then fast paced FPS games, is, that you have more time to predict its outcome. When you shoot a bullet, you need to consider the effect instantly, whereas when you fire a fireball you have several (milli-)seconds time to tell the client and server, that a fireball is flying along a predictable curve.

 

The problem is, that you need to get the server and client in syncronisation for each event. If you have a slower game, where you press the button, the character starts to chant a magic spell, the fireball forms up and starts to fly along a path, you have virtually all the time you need to syncronize the client with the servers by telling them, that in t+500ms a fireball will start to travel from point A to point B. With a good connection you don't even need client prediction, this would be unthinkable in a fast paced shooter.

 

Edit: Addtionally, if the game uses  RTS netcode, most likely each command will have a execution delay as lag compensation and a lock-step approach. This could lead to slowing the game down to keep it syncronised, leading to a really smooth game experiences (though sometimes a slow one too).


Edited by Ashaman73, 07 March 2013 - 05:03 AM.


#3 Hodgman   Moderators   -  Reputation: 27622

Like
0Likes
Like

Posted 07 March 2013 - 05:03 AM

The act of firing it is an instant event, so the server can rewind to apply it to the right point in time. Though yes, to fast forward it to the current time with accurate collisions, it would have to test it for collisions in all the frames between the server's current time, and the spawning time.

 

However, if we take the original DOTA as the archetype for these games, it wasn't built on a typical FPS networking model like the Valve documents describe. It was built on War3, which used a typical RTS networking model, as described here: http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php

 

I'm not sure what LoL or DOTA2 use for networking, but there's many more options than the Counter Strike solution.



#4 Firnael   Members   -  Reputation: 182

Like
0Likes
Like

Posted 07 March 2013 - 05:09 AM

I have to admit, the question was more about "Do I have to implement client prediction on every network game ?".

I'll check thoses RTS networking models and get back asap ^^

 

The goal here is to find out if lag compensation is relevent in a coop A-RPG for exemple.



#5 Ashaman73   Crossbones+   -  Reputation: 6691

Like
0Likes
Like

Posted 07 March 2013 - 05:20 AM

"Do I have to implement client prediction on every network game ?"

There are two issues.

 

The first one is, that the client reprensentation of the game world is different to ones of the server and other clients. This is problematic if the player performs a critical action based on the representation of his client. E.g. an aimed headshot in a shooter. In this situation you need prediction and lag compensation to fight the different representations, else the player would most likely hit the wall and not a moving enemy. If you don't need this kind of accuracy, e.g. in a MMORPG or RTS where you click on a target, then perform an action, then you don't really need this kind of counter measures.

 

The second one is feedback. When you perform an action, you want to see feedback as soon as possible. E.g. your character starts to chant the spell, starts a certain animation as soon as the player press the action button. In the meantime the client sends the command to the server and the server propagates the effects to all clients. This is not really prediction, it is more of lag masking, some cheap tricks to buy you some transfer time.



#6 Kylotan   Moderators   -  Reputation: 3329

Like
1Likes
Like

Posted 07 March 2013 - 06:19 AM

I have to admit, the question was more about "Do I have to implement client prediction on every network game ?".

The short answer is: no, certainly not.

The less short answer is: usually a small amount. It's usually wise to implement ways of making sure the client feels that his own character is responsive. This might involve instantly responding to input with animations and audio, or starting movement of the character before a confirmation returns from the server.

But generally, the whole attitude of sending everybody to the Valve site any time they want to know about networking has become a problem. People assume they need to implement complex interpolation, extrapolation, rollback, state replay, etc., when in fact most of this is only there specifically for high speed, low-latency, spatially-sensitive action games of aiming. Besides, not every shooter handles it the way Valve do anyway! So when deciding how to implement your networked game, you must always keep in mind the needs of your specific game, and not assume that copying Valve is always the right thing to do.

#7 Firnael   Members   -  Reputation: 182

Like
0Likes
Like

Posted 07 March 2013 - 07:27 AM

Thanks for the advices.

 

I can easy imagine how to hide possible lag client-side with client-side prediction (at least with graphical and audio feedback of player actions).

 

Now, I was wondering what could be best for let's say a Zelda-like but with coop (not only LAN, so you need to think about sync through the internet).

This is definetely not a really fast-paced shooter which would require the best precision for ex. headshots on running ennemies, while 360 unscope, but it's not a pure RTS/Target-based mmo (AKA click on target => click on spell => spell affect target) either.

I want it to be based on action and therefor need a minimum of precision (WTF BROKEN HITBOX I HIT YOU I SWEAR GOD F*CK THIS LAG).

 

The way it's explained on the Gamasutra article you linked before seems good for a pure RTS, but is it the case for a more action-oriented gameplay ?

If I understood well, all client got the exact same simulation in the same time, but they all live at least 100ms in the past.

I'll read it again (english not my native language, I didn't get all tongue.png).


Edited by Firnael, 07 March 2013 - 08:09 AM.


#8 Kylotan   Moderators   -  Reputation: 3329

Like
0Likes
Like

Posted 07 March 2013 - 08:29 AM

I want it to be based on action and therefor need a minimum of precision

 

You don't much precision for a game like this. You certainly don't need to be rolling back hitboxes or any of that. Do you even need hitboxes? Just have clients act locally, and send the results to the server. The server checks that they look legit, and passes them on to everybody else.



#9 Firnael   Members   -  Reputation: 182

Like
0Likes
Like

Posted 07 March 2013 - 08:51 AM

Well I'm pretty sure I need hitboxes, without them I won't be able to detect collisions Oo

I'll go simple, at least at start and do what you say, do some client-side prediction to give a smooth feeling for local player, with server-reconciliation so I don't get useless rollbacks, and see if it's satisfying enough.

What I was affraid of is the time needed by the server to broadcast the new game state to other players, but let's admit it, if you got 200ms latence, any action-based game feels unplayable.

I need to start testing stuff.

 

Thanks a lot smile.png

 

P.S. : I almost forgot, server timestep seems to be the best solution to avoid strange situation when for example you kill a unit, client-prediction shows you its dying animation, but at the time you did this prediction, the unit used a potion and healed. When the server corrects you, you'll see the unit revive and act like "I aint even mad".

I think I should definetely dig on that direction.


Edited by Firnael, 07 March 2013 - 08:59 AM.


#10 Kylotan   Moderators   -  Reputation: 3329

Like
0Likes
Like

Posted 07 March 2013 - 09:23 AM

Well I'm pretty sure I need hitboxes, without them I won't be able to detect collisions Oo

You don't need some server-managed idea of where the hitbox is like shooters do. RTS and RPGs don't usually work that way. It's more a case of comparing distances, and if the target is within range (maybe including a little extra distance to account for lag) then allow the attack.



#11 Firnael   Members   -  Reputation: 182

Like
0Likes
Like

Posted 07 March 2013 - 09:31 AM

Yes it may work for melee attacks, even with projectiles like spells or arrows if you don't wont precise collisions, but you may need them for terrain collisions.



#12 starbasecitadel   Members   -  Reputation: 694

Like
0Likes
Like

Posted 07 March 2013 - 12:48 PM

I'm dealing with a similar issue for a MOBA game (client / authoritative server).

 

 

My current approach is not "correct", and it is cheesy, but it is quick to implement and appears more or less workable so far.

 

I just move the entities about 1/20 the distance between their current position and server position, per frame  (fps = 30).   Network updates are around 10fps.   It seems to smooth things pretty well, and hit-spots seem accurate as well.

 

For a high precision FPS this would not work, and I may find issues with it down the road, but it was quick and apparently effective so far.



#13 Kylotan   Moderators   -  Reputation: 3329

Like
0Likes
Like

Posted 07 March 2013 - 03:03 PM

Yes it may work for melee attacks, even with projectiles like spells or arrows if you don't wont precise collisions, but you may need them for terrain collisions.

That's completely separate from the networking though. Of course you need ways to check collision, which may or may not be a hitbox, but you don't need a complex hitbox that can be tracked through time like the Valve ones do.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS