Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (679)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (733)
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 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.
2  Game Development / Game Play & Game Design / Re: A good game architecture and design on: 2013-07-11 17: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 16: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 16: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:

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-24 23: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]
Hydroque (20 views)
2016-05-26 14:45:46

Mac70 (41 views)
2016-05-24 21:16:33

theagentd (43 views)
2016-05-14 18:38:35

theagentd (77 views)
2016-05-10 22:37:41

theagentd (85 views)
2016-05-10 22:33:46

IanParcs (111 views)
2016-04-18 14:18:53

KaiHH (110 views)
2016-04-18 08:35:41

KaiHH (132 views)
2016-04-15 12:43:58

theagentd (136 views)
2016-04-14 02:16:17

theagentd (159 views)
2016-04-14 02:15:43
FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50 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!