Version: 2020.2
LanguageEnglish
  • C#

CharacterController

class in UnityEngine

/

Inherits from:Collider

/

Implemented in:UnityEngine.PhysicsModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

A CharacterController allows you to easily do movement constrained by collisions without having to deal with a rigidbody.

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.

See Also: Character Controller component and Character animation examples

Properties

centerThe center of the character's capsule relative to the transform's position.
collisionFlagsWhat part of the capsule collided with the environment during the last CharacterController.Move call.
detectCollisionsDetermines whether other rigidbodies or character controllers collide with this character controller (by default this is always enabled).
enableOverlapRecoveryEnables or disables overlap recovery. Enables or disables overlap recovery. Used to depenetrate character controllers from static objects when an overlap is detected.
heightThe height of the character's capsule.
isGroundedWas the CharacterController touching the ground during the last move?
minMoveDistanceGets or sets the minimum move distance of the character controller.
radiusThe radius of the character's capsule.
skinWidthThe character's collision skin width.
slopeLimitThe character controllers slope limit in degrees.
stepOffsetThe character controllers step offset in meters.
velocityThe current relative velocity of the Character (see notes).

Public Methods

MoveSupplies the movement of a GameObject with an attached CharacterController component.
SimpleMoveMoves the character with speed.

Messages

OnControllerColliderHitOnControllerColliderHit is called when the controller hits a collider while performing a Move.

Inherited Members

Properties

attachedArticulationBodyThe articulation body the collider is attached to.
attachedRigidbodyThe rigidbody the collider is attached to.
boundsThe world space bounding volume of the collider (Read Only).
contactOffsetContact offset value of this collider.
enabledEnabled Colliders will collide with other Colliders, disabled Colliders won't.
isTriggerIs the collider a trigger?
materialThe material used by the collider.
sharedMaterialThe shared physic material of this collider.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

ClosestPointReturns a point on the collider that is closest to a given location.
ClosestPointOnBoundsThe closest point to the bounding box of the attached collider.
RaycastCasts a Ray that ignores all Colliders except this one.
BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagIs this game object tagged with tag ?
GetComponentReturns the component of Type type if the GameObject has one attached, null if it doesn't. Will also return disabled components.
GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the component of Type type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.

Messages

OnCollisionEnterOnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
OnCollisionExitOnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
OnCollisionStayOnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
OnTriggerEnterWhen a GameObject collides with another GameObject, Unity calls OnTriggerEnter.
OnTriggerExitOnTriggerExit is called when the Collider other has stopped touching the trigger.
OnTriggerStayOnTriggerStay is called almost all the frames for every Collider other that is touching the trigger. The function is on the physics timer so it won't necessarily run every frame.