CharacterController
A CharacterController allows you to easily do movement constrained by collisions without having to deal with a rigidbody.
Read time 8 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
- Inherits from: Collider
public class CharacterController : Collider
Remarks
A CharacterController is not affected by forces and will only move when you call the Move function. It will then carry out the movement but be constrained by collisions.
Additional Resources: Character Controller component and Character animation examples
Properties
Property | Description |
|---|---|
| center | The center of the character's capsule relative to the transform's position. |
| collisionFlags | What part of the capsule collided with the environment during the last CharacterController.Move call. |
| detectCollisions | Determines whether other rigidbodies or character controllers collide with this character controller (by default this is always enabled). |
| enableOverlapRecovery | Enables or disables overlap recovery. Enables or disables overlap recovery. Used to depenetrate character controllers from static objects when an overlap is detected. |
| height | The height of the character's capsule. |
| isGrounded | Was the CharacterController touching the ground during the last move? |
| minMoveDistance | Gets or sets the minimum move distance of the character controller. |
| radius | The radius of the character's capsule. |
| skinWidth | The character's collision skin width. |
| slopeLimit | The character controllers slope limit in degrees. |
| stepOffset | The character controllers step offset in meters. |
| velocity | The current relative velocity of the Character (see notes). |
Methods
Method | Description |
|---|---|
| Move | Supplies the movement of a GameObject with an attached CharacterController component. |
| OnControllerColliderHit | OnControllerColliderHit is called when the controller hits a collider while performing a Move. |
| SimpleMove | Moves the character with speed. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |