I have read tons of articles and forums threads about ECS but still can't understand how anything in engine should communicate with Collision System. Let's say I have Input System that handle keyboard input and then at some point it want to move player character forward. Before doing this I should ask Collision System if there would be a collisions after that move and only if no - change position.

My current approach is to have requestTranslation function in CollisionSystem that take translation function and object like this:

    V3.CollisionSystem.requestTranslation(this.mesh, function(object){

What do you think about this approach? How good/bad it is? What are know alternatives?

  • \$\begingroup\$ This isn't a complete answer, but you may want to use messages, and allow components to listen to and broadcast messages. For collisions, whatever advances the player should probably check if that space is free first before moving the player. \$\endgroup\$
    – ashes999
    Sep 2, 2015 at 14:53
  • \$\begingroup\$ Its possible for systems to communicate implicitly through components. You could also resolve a collision after it happens. \$\endgroup\$
    – user40079
    Sep 2, 2015 at 19:55
  • \$\begingroup\$ Input system should define intention to move. Collision system should check if it can move. But who will do actual move? As for messages - Collision system can send message when collision occur but I need to know if it will occur or not before doing some actions. \$\endgroup\$
    – SET
    Sep 3, 2015 at 9:01

1 Answer 1


As indicated, your Input System signals an intent to perform some action. How your game signals the action is really a matter of taste but the point remains the same.

A Movement System is then a logical step in your game logic thread. It's resposible for taking the intent specified by the Input System and determining velocity/force to be applied to movable entities. The velocity/force is determined based on existing entity state such as whether the entity is running, walking, swimming, flying or has some other speed boost aura applied to it's current state.

Your Physics System takes the calculated velocity/force and applies it to your physics managed entities. This system will determine either a new position for the entity because the movement was allowed or will not move the entity but instead generate a list of collision points. It's here where the magic happens.

At this point you'll need to iterate two types of entities: those with collisions and those without collisions.

For those without; you'll simply want to take the newly calculated position from the physics simulation step and apply that position to the entity's transform component.

For those with a collision; you'll likely want to communicate this collision to remaining parts of the system either via some type of event or callback solution.

To your question in your comment, you simply need to execute whatever logic that needs to know whether a collision happened or not after the physics system has executed it's step in the game loop. It's at this point where you know whether the entity is participating in a collision or not and the ideal place to execute or skip game logic based on this information.


You must log in to answer this question.

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