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:
| Parameter | Usage |
|---|---|
| Motion Type | Motion type, determines if the object is static, dynamic or kinematic |
| Object Layer | The collision layer this body belonds to (determines if two objects can collide) |
| Mass | The mass of the object. If not provided, Jolt will generate a mass value based on the collision shape. |
| Friction | Friction of the body. Should be between 0 and 1 |
| Restitution | Restituion of the body. Should be between 0 and 1, where 0 is a fully inelastic collision and 1 is a fully elastic collision |
| Angular Damping | Angular damping \(\frac{d\omega}{dt} = -c\omega\). Must be between 0 and 1, but is usually closer to 0 |
| Linear Damping | Linear damping \(\frac{dv}{dt} = -cv\). Must be between 0 and 1, but is usually closer to 0 |
| Gravity Factor | How 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