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:

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

Character controller component

Character Controller Component
Character Controller Component

Character Controller

character_controller

Character controller used for movement constrained by collisions without having to deal with a rigid body. A character controller is kinematic, and so is not affected by forces. It uses its own tweaked collision algorithm to give a good feeling while controlling the character.

skinWidth

Float

Default: 0

The character's collision skin width.

slopeLimit

Float

Default: 45

Slope limit in degrees. A slope steeper than the slopeLimit will not be walkable by the controller.

stepOffset

Float

Default: 0

Step offset. If the height of a step is greater than stepOffset, the controller cannot climb automatically and gets stuck.

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.