Skip to main content

Physics Bodies

There are different kinds of physics bodies you can create in 3dverse: static body, rigid body, and kinematic rigid body.

Note that these bodies are all rigid bodies in the classical sense, in that they stay solid and do not deform during collision.

The main difference between the static body and rigid body is that the former is static (expected not to move) during simulation whereas the latter is dynamic (expected to move).

Each of these physics bodies require you to attach some kind of geometry to them which will define their geometry in the physics engine.

info

Every physics body must have a physics_material and some sort of geometry component.

Static Body

When to use a static body?

For an entity that will not move during simulation such as a wall, the ground, or a building.

A static body will not be affected by forces such as gravity.

To make your entity a static body it needs the following components:

Rigid Body

When to use a rigid body?

For an entity that that you want to be affected by forces such as gravity. Collision resolution of rigid bodies is made to seem very “physically accurate”.

A rigid body will collide against all other physics bodies.

To make your entity a rigid body it needs the following components:

Kinematic Rigid Body

When to use a kinematic rigid body?

For an entity that you want to move manually during simulation (e.g. by affecting its transform), such as a rotating door. A kinematic rigid body will not be affected by any forces such as gravity.

If you move a kinematic rigid body it will collide against rigid bodies, but not against static or kinematic rigid bodies (i.e. if you move it into a static body or another kinematic rigid body, it will go through, but if you move it into a rigid body, this will move your rigid body).

To make your entity a kinematic rigid body it needs the following components:

Character Controller

See Character Controller.

Trigger

A trigger physics body is a physics body with isTrigger set to true in its physics_material component.

When to use a trigger?

Make your physics body a trigger if you want to be notified of and react to collisions (in a script or in your application code) that involve that trigger body. Trigger bodies do not have any collision resolution though, they are simply collision “sensors”.

Trigger bodies are used for triggering events, and whatever collision that may occur with them is detected, but not resolved by the physics engine. A trigger event allows a developer to react to two entities colliding and apply some logic to that. See Physics-Based Events for more info on trigger events.

Best Practices

The recommendations of “when to use” each physics body are best practices.

For example, a static body is recommended for a non-moving entity. Although you probably shouldn’t, don’t be surprised if you can actually move a static body during simulation by changing its transform. However, collision detection may not work as well and you may get unexpected results because of the way the physics engine is optimized.

So it’s important to configure your physics bodies correctly and follow the recommendations outlined in this doc.

Enable debug lines!

To see what the physics engine sees, enable debug lines. This will allow you to verify if your physics bodies have been well set up. If you can see the debug lines of your geometry, that means your entity has been well registered inside the physics engine. See Debug Lines for further info.