2
\$\begingroup\$

What are the "smallest" physics components in your component-based game engine?

Would it make sense to create something like Positionable, Rotatable, Movable, Collidable and combine them the way you want or is it better to use one unified component like PhysicsInteractable?

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm voting to close this as it appears to be a survey of what people have individually done, rather than a solveable problem -- it's a social fun / poll and not appropriate for the Stack format. \$\endgroup\$ – doppelgreener May 24 '17 at 13:16
1
\$\begingroup\$

Well, it depends of the overall look of your engine. I have always aimed for static and dynamic objects; the static ones just sit there with their collision data and the dynamic ones get updated and checked against static and other dynamic objects.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This makes sense. Would like to hear more opinions though. \$\endgroup\$ – Den Oct 28 '10 at 12:42
  • \$\begingroup\$ I agree with this. You should split the objects into two categories, the actually movable ones, and ones invisibly anchored to the environment, so they affect other objects, but don't move. \$\endgroup\$ – Tesserex Oct 28 '10 at 13:13
  • \$\begingroup\$ What about (sub)systems? Should there be two separate systems: one for moving and another for collisions? \$\endgroup\$ – Den Oct 28 '10 at 13:25
  • \$\begingroup\$ By doing two systems, you would have to iterate through all your objects twice; one for updating the position, velocity... and other for checking if it collided with something. Just do everything in the same loop: update the properties and check if it intersects something, and then apply bounce/deceleration/etc. \$\endgroup\$ – r2d2rigo Oct 28 '10 at 13:30
1
\$\begingroup\$

Well first of all it depends on what you really need. In 2D Platformer, you don't really need a real rotation value, only for your character to look in the right direction.

Position is the most basic and should be implemented most of the time (maybe not in some really exotic and transcendent gameplay).

Best thing might be to implement a component for every physical aspect you want to check for:

  • is an object collideable, get a collideablecomponent
  • is it movable? Movecomponent
  • does it emit like a force on other objects (like wind from a fan), create a component for that

These should be your atoms, especially in your game engine. Just imagine you want to create something like this:

  • you have components for moving and collision combined, cause everything that moves can collide.

  • now you want something like a ghost (can move, can't collide) and jelly (can't collide, can't move)

Only if you are 100% certain you don't need it, you can go for those hybrids.

What I'm working on is a Node-based system. These are hybrid structures but are gatherings of those atomic Components. An Object may have the moveCollideNode, which is the positionComponent, the moveComponent and the collideComponent.

Edit: What I forget to mention was, that other parts of your engine might need those simple components. Like position and direction for your graphics engine or the object state for controls (just collided and is dizzy, so can't shoot). Someone could manipulate your physic properties in those parts if he has access to that kind of component.

| improve this answer | |
\$\endgroup\$

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