My game is written using a entity system approach using Artemis Framework. Right know my collision detection is called from the Movement System but i'm wondering if it's a proper way to do collision detection using such an approach.

Right know i'm thinking of a new system dedicated to collision detection that would proceed all the solid entities to check if they are in collision with another one.

I'm wondering if it's a correct way to handle collision detection with an entity system approach? Also, how should i implement this collision system?

I though of an IntervalEntitySystem that would check every 200ms (this value is chosen regarding the Artemis documentation) if some entities are colliding.

protected void processEntities(ImmutableBag<Entity> ib) {
    for (int i = 0; i < ib.size(); i++) {
        Entity e = ib.get(i);
        //check of collision with other entities here
  • \$\begingroup\$ See the five points in my answer here. This question will likely be closed as a duplicate. \$\endgroup\$
    – Engineer
    Oct 28, 2012 at 19:55
  • \$\begingroup\$ Logically speaking there should be no collision checking in your movement system. Movement system implies that it handles movement. \$\endgroup\$
    – Sidar
    Oct 28, 2012 at 20:28
  • \$\begingroup\$ @Sidar - collision affects movement, not only post factum, but also sometimes during the movement by limiting it. \$\endgroup\$ Oct 29, 2012 at 17:37
  • \$\begingroup\$ @MarkusvonBroady It still happens in one order. In Artemis you decide that order by the way you add the systems. Sure collision affects movement, but what about the action that needs to be triggered afterwards? Are we just talking about movement here? I don't think collision needs to be hidden in the movement system. It's up to Nathan obviously. However breaking collision down to its own system and have your entity have a component that carries the data over to a system that applies these responses. Personally I don't think it should be in a movement system. \$\endgroup\$
    – Sidar
    Oct 29, 2012 at 19:11
  • \$\begingroup\$ He could always consider a Physics System/Component. But keep in mind that not all objects need physics but still need a movement. \$\endgroup\$
    – Sidar
    Oct 29, 2012 at 19:15

1 Answer 1


Ideally, MovementSystem should process movement only, and there should be a separate system for collision detection/reaction. The only benefit I see from processing collisions in the movement system is that you could use the same loop that processes movement to process collisions, so it would be more efficient.
But unless your game had performance issues due to logic updates taking too long, I would move collision detection/reaction to a separate CollisionSystem which is processed after MovementSystem. This would be a cleaner solution in my opinion.

And, about your last question, I would check for collisions each frame. Checking every 200ms can lead to entities colliding without being detected in some cases.
This might depend on the kind of game that you're making, the speed your entities are moving at, your game update frame rate...

EDIT: In response to this question:

Also i'm wondering what the movement system should do regarding this approach. ATM, my movement system look at the Velocity component of all the concerned entities and do a simple translation of the entity coordinates but since the collision calculations are made in another system, i would need to know the "old" and move the entity to his hold position in case of collision. I'm not really fan of this. – nathan

The movement system should update the current position of each entity, just as you describe.
When you react to collisions it isn't necesary to know the last position of each entity. If you don't want an entity to break through another one, you could calculate the projection vector of the overlap and use it to resolve the collision. This article explains very well how to detect simple collisions and how to calculate the projection vector using the Separating Axis Theorem (SAT).

  • \$\begingroup\$ Hey. Thanks for the answer, please look at my last comment on my question. Actually my game will need to handle a lot of moving entities so collision efficiency is an issue. \$\endgroup\$
    – nathan
    Oct 29, 2012 at 20:36
  • \$\begingroup\$ @nathan I've edited my answer, take a look at it. \$\endgroup\$
    – miviclin
    Oct 29, 2012 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .