Skip to main content

Character Controller

A character controller is a special type of physics body that uses its own collision resolution which is geared for user-controlled characters. Use a character controller for an entity that you can consider kinematic (i.e. controlled by user inputs, not affected by forces like gravity), but is also your main playable character. A character controller will benefit from continuous collision detection and its own collision resolution algorithm that has been tweaked to provide a good feeling while controlling the player.

To make your entity a character controller it needs the following components:

  • Character Controller
  • Physics Material
  • one geometry component from this list:
    Capsule Geometry
    ,
    Box Geometry

Between the two, the capsule geometry is the recommended default choice.

Character controller component

Character Controller Component
Character Controller Component

Character Controller

character_controller

Kinematic character controller for collision-constrained movement without a rigid body. Uses tuned collision handling for responsive control.

Requires

and one of

Schema

skinWidth

Float(m)

Default:0

Collision skin width (meters).

slopeLimit

Float(deg)

Default:45

Maximum walkable slope (degrees). Slopes steeper than this are not walkable.

stepOffset

Float(m)

Default:0

Maximum climbable step height. Steps higher than this cannot be climbed automatically.

Orientation of character controllers

There’s a slight caveat with the box character controller. Unlike other bodies, the box geometry of a character controller will NOT be affected by the orientation of your entity. The box always has a fixed rotation even when the player is (visually) rotating.

However, the capsule character controller will be impacted by the orientation of your entity. The orientation of your entity will be multiplied to the axis vector of your capsule, which will decide the capsule’s orientation.

How to move a character controller

The character controller is moved by affecting its displacement in the character controller component. The displacement attribute in the character controller is an engine-only attribute, and so is not viewable in the editor, but is accessible in scripts. The physics engine will try to move the character controller by the displacement, and do any collision resolution if necessary. The displacement you input will be used to move the character only for that frame; you need to keep updating the displacement each frame you want to keep moving it.

If you need help setting this up, please join our discord.