Class CharacterController
Physical objects that allows to easily do player movement constrained by collisions without having to deal with a rigidbody.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorContextMenu("New/Physics/Character Controller")]
[ActorToolbox("Physics")]
[Unmanaged]
public class CharacterController : Collider, ISerializable
Constructors
CharacterController()
Properties
Flags
Gets the current collision flags. Tells which parts of the character capsule collided with the environment during the last move call. It can be used to trigger various character animations.
Declaration
[Unmanaged]
public CharacterController.CollisionFlags Flags { get; }
Property Value
CharacterController.CollisionFlags
|
Height
Gets or sets the height of the capsule, measured in the object's local space. The capsule height will be scaled by the actor's world scale.
Declaration
[EditorOrder(110)]
[EditorDisplay("Collider", null)]
[ValueCategory]
[Unmanaged]
public float Height { get; set; }
Property Value
System.Single
|
IsGrounded
Gets a value indicating whether this character was grounded during last move call grounded.
Declaration
[Unmanaged]
public bool IsGrounded { get; }
Property Value
System.Boolean
|
MinMoveDistance
Gets or sets the minimum move distance of the character controller. The minimum traveled distance to consider. If traveled distance is smaller, the character doesn't move. This is used to stop the recursive motion algorithm when remaining distance to travel is small.
Declaration
[EditorOrder(230)]
[Limit(0F, 1000F, 1F)]
[EditorDisplay("Character Controller", null)]
[ValueCategory]
[Unmanaged]
public float MinMoveDistance { get; set; }
Property Value
System.Single
|
NonWalkableMode
Gets or sets the non-walkable mode for the character controller.
Declaration
[EditorOrder(215)]
[EditorDisplay("Character Controller", null)]
[Unmanaged]
public CharacterController.NonWalkableModes NonWalkableMode { get; set; }
Property Value
CharacterController.NonWalkableModes
|
Radius
Gets or sets the radius of the sphere, measured in the object's local space. The sphere radius will be scaled by the actor's world scale.
Declaration
[EditorOrder(100)]
[EditorDisplay("Collider", null)]
[ValueCategory]
[Unmanaged]
public float Radius { get; set; }
Property Value
System.Single
|
SlopeLimit
Gets or sets the slope limit (in degrees). Limits the collider to only climb slopes that are less steep (in degrees) than the indicated value.
Declaration
[EditorOrder(210)]
[Limit(0F, 100F, 1F)]
[EditorDisplay("Character Controller", null)]
[ValueCategory]
[Unmanaged]
public float SlopeLimit { get; set; }
Property Value
System.Single
|
StepOffset
Gets or sets the step height. The character will step up a stair only if it is closer to the ground than the indicated value. This should not be greater than the Character Controller’s height or it will generate an error.
Declaration
[EditorOrder(220)]
[Limit(0F, 3.40282347E+38F, 1F)]
[EditorDisplay("Character Controller", null)]
[ValueCategory]
[Unmanaged]
public float StepOffset { get; set; }
Property Value
System.Single
|
UpDirection
Gets or sets the character up vector.
Declaration
[EditorOrder(240)]
[EditorDisplay("Character Controller", null)]
[Limit(-1F, 1F, 1F)]
[Unmanaged]
public Vector3 UpDirection { get; set; }
Property Value
Vector3
|
Velocity
Gets the linear velocity of the Character Controller. This allows tracking how fast the character is actually moving, for instance when it is stuck at a wall this value will be the near zero vector.
Declaration
[Unmanaged]
public Vector3 Velocity { get; }
Property Value
Vector3
|
Methods
Move(Vector3)
Moves the character using a 'collide-and-slide' algorithm. Attempts to move the controller by the given displacement vector, the motion will only be constrained by collisions. It will slide along colliders. Result collision flags is the summary of collisions that occurred during the Move. This function does not apply any gravity.
Declaration
[Unmanaged]
public CharacterController.CollisionFlags Move(Vector3 displacement)
Parameters
Vector3
displacement
The displacement vector (in world units). |
Returns
CharacterController.CollisionFlags
The collision flags. It can be used to trigger various character animations. |
SimpleMove(Vector3)
Moves the character with the given speed. Gravity is automatically applied. It will slide along colliders. Result collision flags is the summary of collisions that occurred during the Move.
Declaration
[Unmanaged]
public CharacterController.CollisionFlags SimpleMove(Vector3 speed)
Parameters
Vector3
speed
The movement speed (in units/s). |
Returns
CharacterController.CollisionFlags
The collision flags. It can be used to trigger various character animations. |