Physics simulation

Ethanon Engine uses Box2D for physics simulation. Enabling physics simulation on entities is easy, all you need to do is enable Collidable in the Entity Editor and then choose the body shape in the Physics properties:

Ethanon engine will take the Collision box relative Position and Size to scale Box2D's collision body.

Enabling a physics-managed body to an entity will transfer control over the entity position and angle to the physics engine. It means that, internally, a Box2D's body (b2Body) is created and its simulation begins as soon as the entity is added to scene. Read the "Bodies" section in the Box2D User Manual to learn more about how bodies work.

Circle body diameter will be computed as (Box.size.x + Box.size.y) / 2.

Highlighted properties are described below.

Boolean properties:

  • Is sensor: highlight this option to flag this entity-body as a sensor. A sensor entity detects collision but does not produce a response (collision).
  • Fixed rotation: toggles the fixed rotation. Entity-bodies such as characters may have this characteristic. Such a body should not rotate, even under load.
  • Is bullet: fast moving objects in Box2D can be labeled as bullets. Bullets will perform continuous collision detection with both static and dynamic bodies. You should decide what bodies should be bullets based on your game design.

Floating point values:

  • Density: body density. Usually ranges between 0.0 and 1.0. Dynamic entities must have density greater than 0.0 to behave properly
  • Friction: surface friction. 0.0 means completely slippery and 1.0 produces more friction than a crude piece of rock (just an example)
  • Restitution: describes how much energy collisions against this entity will reflect. 0.0 means no bouncing at all and 1.0 means full force bouncing, which usually can't be seen in nature
  • Gravity scale: gravity intensity over this entity. Usually 1.0

Ethanon engine offers several functions that may be used to control physics simulation global states.

Static and dynamic bodies

Physics-simulated Static entities won't be affected by the force or gravity and it won't react to impulses and collisions. Setting an entity as Static is useful to create static platforms on side scrolling adventure games.

The Box2D User Manual states that "A static body does not move under simulation and behaves as if it has infinite mass. Internally, Box2D stores zero for the mass and the inverse mass. Static bodies can be moved manually by the user. A static body has zero velocity. Static bodies do not collide with other static bodies."

Entitiy-bodies are automatically assigned as dynamic or static according to its entity state.