Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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 1695 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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (29 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (98 views)
2014-12-08 04:46:31

JscottyBieshaar (58 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (76 views)
2014-11-29 21:32:03

toopeicgaming1999 (137 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (37 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org 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‑gaming.org
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!