Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Physics

Physics in TheEngine is powered by Jolt physics. Objects in TheEngine do not have physics by default, and it must be set up using a physics component.

Warning

If you intend to use a Lua script to manually transform the object, then ensure that the object has its motion type set to “kinematic”.

Adding physics to objects

Physics functionality can be added to objects by simply attaching a physics component.

Physics Parameters

A summary of the physics parameters editable in the properties panel is given below:

ParameterUsage
Motion TypeMotion type, determines if the object is static, dynamic or kinematic
Object LayerThe collision layer this body belonds to (determines if two objects can collide)
MassThe mass of the object. If not provided, Jolt will generate a mass value based on the collision shape.
FrictionFriction of the body. Should be between 0 and 1
RestitutionRestituion of the body. Should be between 0 and 1, where 0 is a fully inelastic collision and 1 is a fully elastic collision
Angular DampingAngular damping \(\frac{d\omega}{dt} = -c\omega\). Must be between 0 and 1, but is usually closer to 0
Linear DampingLinear damping \(\frac{dv}{dt} = -cv\). Must be between 0 and 1, but is usually closer to 0
Gravity FactorHow much to scale gravity for this object

Shape Components

Shape components are used to give physics object a collision shape.

Caution

You should only ever attach one shape component to a physics object. Furthermore, a shape component must not be degenerate. That is, it must have a non-zero volume.

The following is a list of shape components currently supported in TheEngine:

  • Box
  • Sphere
  • Heightmap