Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just recently learned about Entity Systems and want to try it out on a real example (I was developing a game recently and want to try to port it over Entity Systems). But I got problem right away. Actually that is two questions in one.

First would be:

In traditional OOP approach I had game loop which was picking action to do for idling units every 100ms (so-called 'turn'). But rendering obviously was run at every game loop iteration. How should I do that? Maybe I need something like individual interval for systems to run? Like RenderingSystem running every Update while AI Systems are running each 100ms. Or maybe there is some better approach which I should use?

Second question would be about about these AI Systems

I understand how to make AI which will manage every unit completely individually. However I have somewhat simultaneous pathfinding for all units which will do:

  1. Mark units that should start moving as 'moving'.
  2. Find path for every 'moving' unit to it's target (basically closest enemy). All 'moving' units aren't considered as obstacles for path but all not-'moving' units considered as obstacles.
  3. Try to move every unit one step at it's path. If can't make step (someone is already standing there) then mark path as invalid (to recalculate at next AI iteration) and move one step in direction of target (if there is free nodes).
  4. Mark all 'moving' units as not-'moving'

Besides there is addition: 3. Before making step we will check if we have enemy around us and instead of moving we will attack that enemy.

So, one AI iteration required to give action to each unit which will be run until it finishes. Then AI should give next action.

How I can make that in Entity System approach? Because in ES all systems are run one-after-another where I need to "jump" beetween them freely. Or maybe I'm overcomplicating things and should do something different instead of "jumping" between systems?

share|improve this question
Not trying to be rude, but you should use some question marks to denote the questions. – Den Jul 11 '13 at 20:02
I agree, I have no idea what you are asking, because your post does not seem to contain any questions. – Anonymous Entity Jul 15 '13 at 10:32
I denoted questions. Sorry, english isn't my own language. – bobby Jul 15 '13 at 12:59
up vote 0 down vote accepted

RenderingSystem running every Update while AI Systems are running each 100ms.

This shouldn't be a problem. For example, simply have your AI systems accumulate the delta passed to them, and only take action when it exceeds 100ms. I.e. four (dramatically unstable fps) loops could look like this:

aisystem.update(20ms) -> 20ms
aisystem.update(21ms) -> 41ms
aisystem.update(60ms) -> 101ms, take action -> 1ms
aisystem.update(20ms) -> 21ms

Most likely this is not the best way to go about it, but it is one possible implementation.

Or maybe I'm overcomplicating things and should do something different instead of "jumping" between systems?

Correct, you don't want to be jumping between systems. The way I see it, you described one system, not a group of systems. This one system could be called something like AiMovementSystem. And it simply does what you described in your question. I believe you are a bit confused with the definition of System. A System basically iterates through a group of Entities with correct Components -- you don't have a movement system for each entity that should move.

share|improve this answer
First question is gone. Thanks. I edited second question, could you look one more time please? I described way to move units in current OOP approach and I don't know how to do same thing in ES. – bobby Jul 15 '13 at 13:01
@bobby I updated the answer. Hope it helps. – vijoc Jul 15 '13 at 14:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.