Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Networking & Multiplayer / Lag compensation model for a projectile-based 2d shooter. on: 2013-07-18 06: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.
2  Game Development / Game Play & Game Design / Re: A good game architecture and design on: 2013-07-11 19:10:41
Do units only attack the closet enemy within range? If so you may want to try adjusting your cell size to remove unneeded collision checks (a collision being an enemy collides with a units sight circle). Start with cells that are very small then expand outward until you get a candidate. Is it the case that units are only going to change their attack target if someone in those cell sets moves? An easy optimization is to only check for a new target if the nearby enemies have moved. Be sure your units are only checking the distance to relevant entities, such as not people on the same team. If you're using the distance formula to check who to attack, keep in mind that sqrt() is more expensive than just using radius^2 for everything.
3  Game Development / Networking & Multiplayer / Re: Evaluation of highscore implementation methods on: 2013-07-11 18:35:25
Do you have your own server to store these on? It shouldn't be too hard to write a java program that listens for score objects and writes them to a "high scores" file. You'll want to be sure to keep a read-only version of the "high scores" file so that players can quickly get the list and not block on other players who are writing to the file.
4  Game Development / Networking & Multiplayer / Re: [Kryonet] How to efficiently send movement updates? on: 2013-07-11 18:29:19
A very quick optimization you can make here is to only send player positions for players who moved during that frame. If a client gets a packet that makes no mention of player_foo then player_foo much be in the same place he was last frame. Another trick is to know how little data you can get away with sending, for example, can you use a short instead of a float to update the clients?

Unless you have some sort of client-side interpolation, the game is going to look jumpy since networks are unreliable. The better your interpolation is, the slower the server can run and clients won't notice it. I highly recommend taking the time to read some common tricks that games use to hide the instability and delays of a network. I would suggest these for reading:

https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization

Even though these methods are used by a 3d game, they translate over just as well to a 2d game.
5  Game Development / Networking & Multiplayer / Multiple DatagramChannel read/write vs Single Channel send/receive on: 2013-06-25 01:03:11
This question is with regards to a single server -> multiple clients udp-based game.

The java nio Datagram Channel and its "connect" ability seems pretty useful for speeding up a server by giving using a datagram channel to talk to each client. The documentation says connecting a channel will let us "avoid the overhead of the security checks". A downside, however, stems from people generally playing games from behind a router which hides their computer from internet traffic. Fortunately, operating systems will often make a temporary firewall rule on the router that will allow traffic to return from a recent packet destination. So, by sending a packet to the server IP + Port, we can get return traffic from that exactly server IP + Port. If I bind a port on the server for each client, the client doesn't know what port it is going to be provisioned / send that initial packet to, so it can't receive packets from the server.

One solution would be to have a separate TCP connection to the server, in which the client requests the connection and gets back the port number it will be using, and then can send a packet to that port to open the firewall.

The other is just to bind one port on the server, and use that to talk to each client.

So my question is this: Just how much does the "connected" datagram channel benefit? Is it really a significant speed difference? For my application, I'm not exactly sending a lot of data (66 tick, < 512 bytes per packet)

The other question: Is there a better way to let the client know what port it is going to be provisioned than spinning up an auxiliary connection with a pre-designated port to let the client know where it'll be?

Thanks for any insight!
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (22 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (54 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!