Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Jan 2011
Offline Last Active Jul 21 2015 02:30 PM

#5236869 Dealing with different collision responses in an entity-component system

Posted by SpaceRoach on 26 June 2015 - 12:09 AM


I use a method which is similar to tiago's but is extremely simplified. I use Bullet physics as my collision detection system, artemis-cpp for the ECS architecture.


  1. Bullet has a function performDiscreteCollisionDetection() (or stepSimulation() if you want dynamics as well). After calling this, all overlapping pairs (ie colliding objects) will be available in an array that bullet maintains internally.
  2. Loop over this array (note: it's an array of btCollisionObjects so use the userPointer field to get the entity) and add a collided component to the entities in each pair
  3. The collided component in one entity stores the id of the other entity.

Here is the system logic

  • All entities having the collided component as well as a health component will have their health reduced by the amount in the other entity's damage component
  • All entities having the collided component as well as a Damage component will just destroy themselves

For your case, you can store additional info in the collided component, and use that to update the transforms of your entities so they no longer collide.

Ofcourse this might be a poor method to do this, but hopefully you can see how a collision detection system can cooperate with entities and systems.

#5221805 Basic enemy design

Posted by SpaceRoach on 07 April 2015 - 04:41 AM

How about this ?