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 (844)
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 System - Networking  (Read 7026 times)
0 Members and 1 Guest are viewing this topic.
Offline seismic

Senior Devvie

Medals: 4
Projects: 1

« Posted 2014-03-30 17:27:17 »


I know
Entity Systems will not get your game done

etc. etc. Cheesy

Anyway, maybe someone can give me some insight to this. I'm using Artemis Entity System ( which is pretty easy to setup and use and I have really become a big fan of it. Now I have implemented the *most* simple client/server using Kryonet (server trusts the clients, clients just send positional updates at ~30 times per second, server distributes updates to the other clients, you know the drill), which also works fine.

But here comes the "problem". I'm not 100% sure about my way of implementation in regards to the entity system, because what I do now is:

* Client and Server both have their own entity system world (server runs on another thread).
- Client sends positional update to the server (I know, I know Cheesy).
- Server receives update and updates the corresponding entity (the player) the moment it receives the update.
- Server sends the update to the clients and they update the entity the moment they receive it

Now the last 2 parts are what concerns me. I don't know if that is the right way to go about networking in an entity system. If you tried an entity system you know the systems iterate through their components on every frame and *then* do their magic. I'm just not sure how to implement an "this-entity-received-an-update-so-update-it-on-the-next-turn" system.

I know it doesn't really matter in "the most simple client-server-game-thing", performance-wise, but I want to know the "correct" way to go about this.

Maybe someone here has done something like this before and can give some insight into this?

Thanks a lot Smiley

Offline breno.inojosa

Junior Newbie

« Reply #1 - Posted 2014-03-31 06:40:20 »

So... I'm not using Artemis Entity System because I created my own..

Basically, whenever I create a specific type of entity, I add it to a tree. Both in Client and Server. Works the same way.
When you receive a package that applies "Move X to the right", search for the entity in the tree and make your changes to it. Remember to always use thread-safe collections and consider that your networking events shouldn't change the order of the updates or change whatever is already built..

Not sure if I was clear.
Offline seismic

Senior Devvie

Medals: 4
Projects: 1

« Reply #2 - Posted 2014-03-31 10:53:06 »

Yep, so you update the entities the moment they're received on the client/server, not during the component-update-iteration loop. It's what I do too, I was just wondering if it's the "right way".

Thanks tho Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline junkdog
« Reply #3 - Posted 2014-03-31 15:01:47 »

Vanilla artemis hasn't been updated for quite some time and has a number of bugs. You're better off using a fork, like mine or this one.

artemis-odb: bugfixing and performance optimized fork of artemis ECS
Offline seismic

Senior Devvie

Medals: 4
Projects: 1

« Reply #4 - Posted 2014-04-09 06:14:18 »

I am using yours <3 Cheesy
Just didn't mention it Smiley

Btw. I just update the components the moment they're received now via
entity.getComponent(Component.class).field = updatedField;

Don't think it has a huge performance impact anyway. Shouldn't be much slower than adding it to a queue and have the component update on the next system-iteration. Listening to myself, it's probably faster :p
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

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