Colliders

To use physics in your project, add a collider component to an entity.

Colliders define the shapes and rules of physics objects. There are three types:

  • don't move (eg walls, floors, heavy objects, etc)
  • rigidbodies are moved around by forces such as collision and gravity (eg balls, barrels, etc)
  • set the

  • make triggers, and detect when objects pass through them
  • constrict collider movement with

Colliders interact according to the table below.

  • "Collisions" refers to collision information and events only. This means the collision is detected in the code, but the objects don't bump into each other (no dynamic response).

  • "Dynamic" means both collision information and events, plus dynamic response (ie the colliders bump into each other instead of passing through).

By default, colliders are invisible in the Scene Editor. To show them:

  • In the Game Studio toolbar, in the top right, click the Display gizmo options icon.

  • Select Physics.

Display physics option

The Scene Editor displays collider shapes.

You can make colliders visible at runtime, which is useful for debugging problems with physics. To do this, use:

Note

To show or hide collider shapes at runtime with a keyboard shortcut, use the Debug physics shapes script.

  • In the Asset View, click Add asset.

Add debug physics shape script

  • In the Game Studio toolbar, click Reload assemblies and update scripts.

  • Add the Debug physics shapes script as a component to an entity in the scene. It doesn't matter which entity.

Add debug physics shapes script component

The script binds the collider shape visibility to Left Shift + Left Ctrl + P, so you can turn it on and off at runtime. You can edit the script to bind a different key combination.