Skip to content

Physics

VMormoris edited this page Oct 30, 2022 · 1 revision

Physics

Green Tea has only 3 types of components (currently) to make entities obey Newton's laws: Rigidbody2D, BoxCollider, CirlceCollider. To make all this happen the Engine uses a library name: box2d. Reading the documentation of the library might prove helpfull to you if you want to have a full understanding of how things work.

It is important to note here that not all entities are handled by box2d. In order for an entity to handled by box2d it must have both a Rigidbody and one of the previously mention colliders. It's also very important to understand that entities that are handled by box2d should only be update the Transformations and Velocities during the FixedUpdate method.

Rigidbodies

According to box2d a rigidbody is: "A chunk of matter that is so strong that the distance between any two bits of matter on the chunk is constant. They are hard like a diamond." They are three types of Rigidbodies:

  • Static bodies are not affected by gravity forces and wouldn't move by changing their Velocity. Static bodies also don't collide with other type rigidbodies expect the dynamics ones.
  • Kinematic bodies are moved by their Velocity but not are affected by the gravity forces. Kinematic bodies also don't collide with other types rigidbodies expect the dynamics ones.
  • Dynamic bodies are movable objects that are affected by the gravity forces. Dynamic bodies collide with all other types rigidbodies, as well as between them.

Colliders

  • BoxCollider gives a box like shape to the entity that is attached to. It enables the entity to collide with others.
  • CircleCollider give a circle shape to the entity that is attached to. It enables the entity to collide with others.

Clone this wiki locally