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  
  Entity management for server / client  (Read 3160 times)
0 Members and 1 Guest are viewing this topic.
Offline zngga
« Posted 2012-08-05 19:56:36 »

I am working on a multiplayer RTS and am having difficulty deciding how to manage the games entities across all the clients. How I have the server/client implementation set up is like this: Game creator is the Host (Server runs in background on their computer) Players join this server via an IP address, or by LAN discovery. The server maintains all the entities for the game (units, buildings, projectiles, etc...) running update logic on them as if it was a single player implementation. My trouble comes in here though: what would be the best way to represent these entities on the clients? The client side doesn't need to worry about update logic, only rendering and gathering commands from the player. My first thought was to have an exact copy of the servers entities on each client, and the server would send out game state snapshots to update these, but I feel as if that would be bloated since the clients don't need to run any update logic on these entities. My second thought was to have two implementations of each entity; one for the server, the other for the client. The issue with this approach is obvious... two versions of each entity is hard to maintain, even harder if I ever make changes. Anyway, that is my challenge at the moment, and I would appreciate any insight you can give on ways you would do this, or have done this. Thanks!

My code never has bugs... it just develops unexpected features!
Offline jonjava
« Reply #1 - Posted 2012-08-05 20:09:16 »

Never made a multiplayer RTS but the way I've done it have a "puppet" version/switch on the object. Not necessarily a completely different class file, but simply turned "on" in puppet mode. The puppet simply has a small action queue and is used to draw the things for the clients.

The action queue is mostly used to smoothly transition from place to place. E.g. the server sends 3 x and y coordinated and the puppet walks to each of them in order to make it look smooth. (This is the only thing active in the puppets update() method).

Offline Danny02
« Reply #2 - Posted 2012-08-05 20:31:03 »

it is quite easy.
Just split logic from the data(like in the mvc model).
so you can use the model class on the client and server and only the server uses the logic class.

Then the server can update the model on the client easily.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 65K
« Reply #3 - Posted 2012-08-05 21:39:19 »

I have two classes: Actor on server side, Puppet on client side
There are different properties required, for example, Actors get a Brain for AI, a Scene reference, whereas puppets keep track of past moves for processing server location snapshots.

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Offline zngga
« Reply #4 - Posted 2012-08-07 14:39:31 »

So it seems that the best way will ultimately involve multiple classes representing each entity. From what you have all said, and my research (Google!) I have decided to have the clients and server maintain the same exact list of entities, but I am removing all update and render logic from these entity classes. The server will have command modules to handle commands from the clients, and update modules; one for each entity type (as there update logic will be different) and the client will have rendering, input handling, and a module to handle snapshots from the server. I also want to implement a blackboard for the entities, but one step at a time!

My code never has bugs... it just develops unexpected features!
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

Solater (139 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!