class CharacterController

Inherits: Component

Special physics controller meant to be used for game characters.

Uses the "slide-and-collide" physics instead of of the standard physics model to handle various issues with manually moving kinematic objects. Uses a capsule to represent the character's bounds.

Public

Constructors

CharacterController

CharacterController(const HSceneObject &parent)

Methods

Move

CharacterCollisionFlags Move(const Vector3 &displacement)

Moves the controller in the specified direction by the specified amount, while interacting with surrounding geometry.

Returns flags signaling where collision occurred after the movement.

Does not account for gravity, you must apply it manually.

SetFootPosition

void SetFootPosition(const Vector3 &position)

Determines the position of the bottom of the controller.

Position takes contact offset into account. Changing this will teleport the character to the location. Use Move() for movement that includes physics.

GetFootPosition

Vector3 GetFootPosition() const

SetRadius

void SetRadius(float radius)

Determines the radius of the controller capsule.

GetRadius

float GetRadius() const

SetHeight

void SetHeight(float height)

Determines the height between the centers of the two spheres of the controller capsule.

GetHeight

float GetHeight() const

SetUp

void SetUp(const Vector3 &up)

Determines the up direction of capsule.

Determines capsule orientation.

GetUp

Vector3 GetUp() const

SetClimbingMode

void SetClimbingMode(CharacterClimbingMode mode)

Controls what happens when character encounters a height higher than its step offset.

GetClimbingMode

CharacterClimbingMode GetClimbingMode() const

SetNonWalkableMode

void SetNonWalkableMode(CharacterNonWalkableMode mode)

Controls what happens when character encounters a slope higher than its slope offset.

GetNonWalkableMode

CharacterNonWalkableMode GetNonWalkableMode() const

SetMinMoveDistance

void SetMinMoveDistance(float value)

Represents minimum distance that the character will move during a call to Move().

This is used to stop the recursive motion algorithm when the remaining distance is too small.

GetMinMoveDistance

float GetMinMoveDistance() const

SetContactOffset

void SetContactOffset(float value)

Contact offset specifies a skin around the object within which contacts will be generated.

It should be a small positive non-zero value.

GetContactOffset

float GetContactOffset() const

SetStepOffset

void SetStepOffset(float value)

Controls which obstacles will the character be able to automatically step over without being stopped.

This is the height of the maximum obstacle that will be stepped over (with exceptions, see ClimbingMode).

GetStepOffset

float GetStepOffset() const

SetSlopeLimit

void SetSlopeLimit(Radian value)

Controls which slopes should the character consider too steep and won't be able to move over.

See NonWalkableMode for more information.

GetSlopeLimit

Radian GetSlopeLimit() const

SetLayer

void SetLayer(u64 layer)

Determines the layer that controls what can the controller collide with.

GetLayer

u64 GetLayer() const

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Fields

OnColliderHit

Event<void (const ControllerColliderCollision &)> OnColliderHit

Triggered when the controller hits a collider.

OnControllerHit

Event<void (const ControllerControllerCollision &)> OnControllerHit

Triggered when the controller hits another character controller.

Protected

Constructors

CharacterController

CharacterController()

Methods

OnDestroyed

void OnDestroyed() override

Called once just before the component is destroyed.

Called regardless of the state the component is in.

OnDisabled

void OnDisabled() override

Called every time a component is placed into the Stopped state.

This includes component destruction if component wasn't already in Stopped state during destruction. When called during destruction it is called before OnDestroyed.

OnEnabled

void OnEnabled() override

Called every time a component leaves the Stopped state, if the component is enabled.

This includes component creation if requirements for leaving the Stopped state are met. When called during creation it is called after OnBeginPlay.

OnTransformChanged

void OnTransformChanged(TransformChangedFlags flags) override

Called when the component's parent scene object has changed.

Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().

UpdateSceneObjectPositionFromController

void UpdateSceneObjectPositionFromController()

Updates the position by copying it from the controller to the component's scene object.

UpdateDimensions

void UpdateDimensions()

Updates the dimensions of the controller by taking account scale of the parent scene object.

DestroyInternal

void DestroyInternal()

Destroys the internal character controller representation.

TriggerOnColliderHit

void TriggerOnColliderHit(const ControllerColliderCollision &value)

Triggered when the internal controller hits a collider.

TriggerOnControllerHit

void TriggerOnControllerHit(const ControllerControllerCollision &value)

Triggered when the internal controller hits another controller.

Fields

mImplementation

mInformation

mLayer

u64 mLayer