Entity Component Model Collisions
Hello,
When using the Entity Component Model, what is generally accepted to be the best method for collision checks?
Does the Collision Component simply listen for collisions or does it actually check for collisions?
When using the Entity Component Model, what is generally accepted to be the best method for collision checks?
Does the Collision Component simply listen for collisions or does it actually check for collisions?
How about,
1, Entity provides the collision data (shape, etc), maybe via a component (collision data component),
2, A sub system, processes all collision data in each frame.
3, If any collision occurs, the sub system just emits an event.
4, Any interesting component subscribes to the events. An AI component of an enemy may want to know when the hero hits the ground, etc.
1, Entity provides the collision data (shape, etc), maybe via a component (collision data component),
2, A sub system, processes all collision data in each frame.
3, If any collision occurs, the sub system just emits an event.
4, Any interesting component subscribes to the events. An AI component of an enemy may want to know when the hero hits the ground, etc.
wqking,
Your proposal is similar to the architecture I decided to use last night. After doing some research I found this:
http://www.gamadu.com/artemis/
I really like the idea of every bit of ingame logic being a 'system'. However, I was still having issues figuring out where to generate events.
I guess having a global collision detection system would be the best way. Then, I would have to use a listener structure for collision events, like you sugguested.
Your proposal is similar to the architecture I decided to use last night. After doing some research I found this:
http://www.gamadu.com/artemis/
I really like the idea of every bit of ingame logic being a 'system'. However, I was still having issues figuring out where to generate events.
I guess having a global collision detection system would be the best way. Then, I would have to use a listener structure for collision events, like you sugguested.
An alternative of listener is that, register a component which is to response collision, such like a CollisionSolverComponent.
When collision occurs, the sub system just try to find if there is CollisionSolverComponent in the entity, if there is one, call special function on it.
This method is more coupled, but may (or may not) be more efficient than event dispatch.
Of course CollisionSolverComponent can listen to the events, then no need of the component look up.
When collision occurs, the sub system just try to find if there is CollisionSolverComponent in the entity, if there is one, call special function on it.
This method is more coupled, but may (or may not) be more efficient than event dispatch.
Of course CollisionSolverComponent can listen to the events, then no need of the component look up.
OK, for the purposes of performance, I don't believe it's efficient to have each object have its own subsystem to check for collisions. This is because the world object list must be accessed multiple times and, due to the limitations of Java, I must create an array version of my list in order to use it and modify the object at the same time. Thus, I think the most elegant solution is probably a CollisionHandlerComponent like you suggested, and stick the CollisionGeneratorComponent into the WorldEntity.
"each object have its own subsystem" ?
I think you misunderstand about sub system.
A sub system is NOT for any single object, it's for the whole sub behavior, which may include a lot of entities or components.
For example, a game may have several sub systems, rendering sub system, resource management SS, physics and collision SS, etc.
If an entity needs to render itself, just provide data to rendering sub system.
So an entity, or an object, doesn't have any sub system. Sub system is in quite global and top level.
I think you misunderstand about sub system.
A sub system is NOT for any single object, it's for the whole sub behavior, which may include a lot of entities or components.
For example, a game may have several sub systems, rendering sub system, resource management SS, physics and collision SS, etc.
If an entity needs to render itself, just provide data to rendering sub system.
So an entity, or an object, doesn't have any sub system. Sub system is in quite global and top level.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement