Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Lag compensation model for a projectile-based 2d shooter.  (Read 3048 times)
0 Members and 1 Guest are viewing this topic.
Offline Shnagenburg

Junior Newbie

« Posted 2013-07-18 04:41:59 »

I've been researching/pondering a good way to set up the lag compensation techniques for a 2d shooter where the attacks are mostly, if not all, projectile based (i.e. a rocket). Imagine the game features 2-8 players moving about their body's distance in half a second. A rough cut of what a lot of modern day shooters do follows:

1. Player sees all other players some interval in the past. Say, an arbitrary 100 ms. This way the game feels very "smooth" as the other players run around (interpolation)
2. Player sees itself in the present, and predicts where it should be. If all goes well, it guess correctly and so the game feels "instant" to the player. (client-side prediction)
3. Player aims at someone in the past. If he fires a weapon, the server rewinds everyone BUT the player who fired and checks for hits. (reverse-...something)

Unfortunately with projectiles, number 3 is a little more tricky, how's best to go about firing a rocket? We've got some options here with pros and cons.

Lets say we're still showing other players 100 ms in the past.

3a. Player fires a rocket and the rocket is rendered in the present. The shot feels instant, but the targets are 100ms in the past, the player would have to lead its shots to score hits.
3b. Player fires a rocket and the rocket is rendered 100ms in the past. Well the collisions are accurate now and no rewinding needs to be done, but this makes the game feel a little less responsive.
3c. Player fires a rocket and the rocket is rendered in the present. The server rewinds everyone to check for rocket hits. This is great for the player, but the other guy getting hit has the short end of the stick because the rocket is being compared against his/her past self. He/She could very well dodge out of the way, but his/her view of the rocket isn't right because he/she is going to get moved back in time. So, to deal with this for the other player. We accelerate the rocket 100ms along its flight path to the other player. This has some other downsides. The rocket on the other player's game wont look quite right; its ignition will be rushed and it would "stick" in the ground for 100ms before it detonates accurately.

This "players viewing everyone else in the past" thing is messing us up; so what if we just skipped the interpolation and rendered everyone in the present via extrapolation?
3d. Player fires a rocket and everything is done in the present.

Well the game becomes more jerky, since players who change direction will move quicker than usual. But, the server no longer needs to rewind the game to check hits. The other nice bit is that rocket's don't have to be fake-accelerated on the other player's game and won't appear to stick in the ground before detonating.

I think that for the simplicity and functionality, 3b. is a very solid choice. The only real downside is that there is a slight delay when firing the rocket. The main reason I would consider implementing 3c is that the game would also be playable on a local machine in split-screen fashion. Since there's no need for lag compensation, the rockets would not be delayed upon firing. This would make the game play differently in local mode and online mode, an inconsistency worth avoiding. Therefor I would think to try 3c. and fiddle with the delay to see how short of a time I could get away with.
Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (863 views)
2018-03-24 14:47:39

ivj94 (124 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!