Work in progress. These docs are new and are likely missing a lot of info. If you notice something wrong or missing, open an issue. PRs are welcome as well.

Rigid bodies

Rigid bodies allow physics simulation to be applied to your Entities

Giving physics to Entities

In editor:

Add aRigidBodyComponent in the editor by seleting the entity in the scene hierarchy, clicking 'Add' > 'Rigid Body Component' under the 'Components' header.

In code (C++):

PhysicsMaterial material;
material.mass = 10.0f;

crate->AddComponent<RigidBodyComponent>(RigidBodyComponent {
    .physicsMaterial = material
});

Mass defaults to 0, which makes the body static: other bodies collide with it, but it doesn't move. Set a mass above 0 to make it dynamic.

Physics material

Property What it does
mass Mass of the body, 0 == static, immovable
friction Surface friction. Starts at 0.5.
restitution Bounciness. Starts at 0.

To give a body a starting velocity, set initialVelocity or initialAngularVelocity on the component

Shapes

The shape defines the collision volume. Make one with Assets › Add... › Physics Shape, and assign it to the component's collision shape. You can pick from:

  • Box, Sphere, Capsule and Plane.
  • Convex hull, wrapped around a mesh.
  • Compound, a mesh decomposed into convex pieces. Use this for complex geometry.
  • Height field, for terrain.

Plane and height field bodies are always static, whatever their mass.

If no shape is set, a box fitted to the entity's bounds is used.

In multiplayer

The server is the authority, and simulates physics for the world.

On clients, replicated bodies don't simulate: they follow the positions and velocities the server sends, interpolating between updates. Bodies that aren't replicated are simulated locally on each client. More in replication.

Improve this page on GitHub