Search Results for

    Show / Hide Table of Contents

    Class CharacterController

    Physical objects that allows to easily do player movement constrained by collisions without having to deal with a rigidbody.

    Inheritance
    Object
    ScriptingObject
    SceneObject
    Actor
    PhysicsColliderActor
    Collider
    CharacterController
    Inherited Members
    Actor::_box
    Collider::_cachedLocalPosePos
    Collider::_cachedLocalPoseRot
    Collider::_cachedScale
    Collider::_center
    Collider::_contactOffset
    Actor::_drawCategory
    Actor::_drawNoCulling
    ScriptingObject::_gcHandle
    ScriptingObject::_id
    Actor::_isActive
    Actor::_isActiveInHierarchy
    Actor::_isEnabled
    Actor::_isHierarchyDirty
    Actor::_isPrefabRoot
    Collider::_isTrigger
    Actor::_layer
    Actor::_localTransform
    Actor::_name
    SceneObject::_parent
    Actor::_physicsScene
    SceneObject::_prefabID
    SceneObject::_prefabObjectID
    Actor::_scene
    Collider::_shape
    Actor::_sphere
    Collider::_staticActor
    Actor::_staticFlags
    Actor::_transform
    ScriptingObject::_type
    Actor::AddMovement(const Vector3& translation)
    Actor::AddScript()
    Actor::AddStaticFlags(StaticFlags flags)
    Actor::AddTag(const Tag& tag)
    Actor::AddTagRecursive(const Tag& tag)
    Collider::Attach(RigidBody* rigidBody)
    CharacterController
    Actor::BreakPrefabLink()
    Collider::CanBeTrigger()
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    ScriptingObject::Cast(ScriptingObject* obj)
    ScriptingObject::ChangeID(const Guid& newId)
    Actor::ChangeScriptOrder(Script* script, int32 newIndex)
    Actor::Children
    Actor::Clone()
    Collider::ClosestPoint(const Vector3& point, Vector3& result)
    PhysicsColliderActor::CollisionEnter
    PhysicsColliderActor::CollisionExit
    CharacterController
    Collider::ComputePenetration(const Collider* colliderA, const Collider* colliderB, Vector3& direction, float& distance)
    Collider::ContainsPoint(const Vector3& point)
    ScriptingObject::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    Collider::CreateStaticActor()
    ScriptingObject::Deleted
    Object::DeleteObject(float timeToLive = 0.0f, bool useGameTime=false)
    Object::DeleteObjectNow()
    Actor::DEPRECATED("Use HasTag instead") const String& GetTag()
    Actor::DEPRECATED("Use AddTag instead") void SetTag(const StringView& value)
    Actor::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
    ISerializable::DeserializeIfExists(DeserializeStream& stream, const char* memberName, ISerializeModifier* modifier)
    CharacterController
    Actor::DestroyChildren(float timeLeft = 0.0f)
    ScriptingObject::DestroyManaged()
    Actor::Draw(RenderContext& renderContext)
    Actor::Draw(RenderContextBatch& renderContextBatch)
    Actor::FindActor(const StringView& name)
    Actor::FindActor(const MClass* type, bool activeOnly=false)
    Actor::FindActor(const MClass* type, const StringView& name)
    Actor::FindActor(const MClass* type, const Tag& tag, bool activeOnly=false)
    Actor::FindActor()
    Actor::FindActor(const Tag& tag)
    Actor::FindScript(const MClass* type)
    Actor::FindScript()
    Object::Flags
    Actor::FromBytes(const Span<byte>& data, Array<Actor* >& output, ISerializeModifier* modifier)
    Actor::FromBytes(const Span<byte>& data)
    Actor::FromBytes(const Span<byte>& data, const Dictionary<Guid, Guid, HeapAllocation>& idsMapping)
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    Actor::FromJson(const StringAnsiView& json)
    Actor::GetBox()
    Actor::GetBoxWithChildren()
    Collider::GetCenter()
    Actor::GetChild(int32 index)
    Actor::GetChild(const StringView& name)
    Actor::GetChild(const MClass* type)
    Actor::GetChild()
    Actor::GetChildren(const MClass* type)
    Actor::GetChildren()
    Actor::GetChildrenCount()
    ScriptingObject::GetClass()
    Collider::GetContactOffset()
    Actor::GetDirection()
    Actor::GetEditorBox()
    Actor::GetEditorBoxChildren()
    ScriptingObject::GetID()
    Actor::GetIsActive()
    Collider::GetIsTrigger()
    Actor::GetLayer()
    Actor::GetLayerMask()
    Actor::GetLayerName()
    Actor::GetLocalOrientation()
    Actor::GetLocalPosition()
    Actor::GetLocalScale()
    Actor::GetLocalToWorldMatrix(Matrix& localToWorld)
    Actor::GetLocalToWorldMatrix(Double4x4& localToWorld)
    Actor::GetLocalTransform()
    ScriptingObject::GetManagedInstance()
    Actor::GetName()
    SceneObject::GetNamePath(Char separatorChar='/')
    Actor::GetOrAddChild()
    ScriptingObject::GetOrCreateManagedInstance()
    Actor::GetOrderInParent()
    Actor::GetOrientation()
    SceneObject::GetParent()
    Actor::GetPerInstanceRandom()
    Actor::GetPhysicsScene()
    Collider::GetPhysicsShape()
    Actor::GetPosition()
    SceneObject::GetPrefabID()
    SceneObject::GetPrefabObjectID()
    Actor::GetPrefabRoot()
    Actor::GetRotation()
    Actor::GetScale()
    Actor::GetScene()
    Actor::GetSceneObjectId()
    Actor::GetSceneRendering()
    Actor::GetScript(int32 index)
    Actor::GetScript(const MClass* type)
    Actor::GetScript()
    Actor::GetScriptByID(const Guid& id)
    Actor::GetScripts(const MClass* type)
    Actor::GetScripts()
    Actor::GetScriptsCount()
    Actor::GetSphere()
    Actor::GetStaticFlags()
    Actor::GetTransform()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Actor::GetWorldToLocalMatrix(Matrix& worldToLocal)
    Actor::GetWorldToLocalMatrix(Double4x4& worldToLocal)
    Actor::HasActorInChildren(Actor* a)
    Actor::HasActorInHierarchy(Actor* a)
    Actor::HasContentLoaded()
    ScriptingObject::HasManagedInstance()
    SceneObject::HasParent()
    SceneObject::HasPrefabLink()
    Actor::HasScene()
    Actor::HasStaticFlag(StaticFlags flag)
    Actor::HasTag()
    Actor::HasTag(const Tag& tag)
    Actor::HasTag(const StringView& tag)
    Actor::HideFlags
    Actor::Initialize()
    Actor::InitializeHierarchy()
    Actor::Intersects(const Ray& ray, Real& distance, Vector3& normal)
    Actor::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    Actor::IsActiveInHierarchy()
    SceneObject::IsDuringPlay()
    Actor::IsPrefabRoot()
    ScriptingObject::IsRegistered()
    Actor::IsStatic()
    Actor::IsTransformStatic()
    Actor::LinkPrefab(const Guid& prefabId, const Guid& prefabObjectId)
    Actor::LookAt(const Vector3& worldPos)
    Actor::LookAt(const Vector3& worldPos, const Vector3& worldUp)
    Actor::LookingAt(const Vector3& worldPos)
    Actor::LookingAt(const Vector3& worldPos, const Vector3& worldUp)
    Collider::Material
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    CharacterController
    Actor::OnActiveChanged()
    Actor::OnBeginPlay()
    PhysicsColliderActor::OnCollisionEnter(const Collision& c)
    PhysicsColliderActor::OnCollisionExit(const Collision& c)
    Actor::OnDebugDraw()
    Actor::OnDeleteObject()
    Actor::OnEndPlay()
    Collider::OnLayerChanged()
    ScriptingObject::OnManagedInstanceDeleted()
    Actor::OnOrderInParentChanged()
    ScriptingObject::OnScriptingDispose()
    Collider::OnStaticFlagsChanged()
    PhysicsColliderActor::OnTriggerEnter(PhysicsColliderActor* c)
    PhysicsColliderActor::OnTriggerExit(PhysicsColliderActor* c)
    Collider::RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, float maxDistance=MAX_float)
    Collider::RayCast(const Vector3& origin, const Vector3& direction, RayCastHit& hitInfo, float maxDistance=MAX_float)
    ScriptingObject::RegisterObject()
    Collider::RemoveStaticActor()
    Actor::RemoveStaticFlags(StaticFlags flags)
    Actor::RemoveTag(const Tag& tag)
    Actor::ResetLocalTransform()
    SceneObject::SceneObject(const SpawnParams& params)
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    Actor::Scripts
    Actor::Serialize(SerializeStream& stream, const void* otherObj)
    CharacterController
    CharacterController
    Collider::SetCenter(const Vector3& value)
    Collider::SetContactOffset(float value)
    Actor::SetDirection(const Float3& value)
    Actor::SetIsActive(bool value)
    Collider::SetIsTrigger(bool value)
    Actor::SetLayer(int32 layerIndex)
    Actor::SetLayerName(const StringView& value)
    Actor::SetLayerNameRecursive(const StringView& value)
    Actor::SetLayerRecursive(int32 layerIndex)
    Actor::SetLocalOrientation(const Quaternion& value)
    Actor::SetLocalPosition(const Vector3& value)
    Actor::SetLocalScale(const Float3& value)
    Actor::SetLocalTransform(const Transform& value)
    ScriptingObject::SetManagedInstance(MObject* instance)
    Actor::SetName(String&& value)
    Actor::SetName(const StringView& value)
    Actor::SetOrderInParent(int32 index)
    Actor::SetOrientation(const Quaternion& value)
    Actor::SetParent(Actor* value, bool worldPositionsStays, bool canBreakPrefabLink)
    Actor::SetParent(Actor* value, bool canBreakPrefabLink=true)
    SceneObject::SetParent(Actor* value)
    Actor::SetPhysicsScene(PhysicsScene* scene)
    Actor::SetPosition(const Vector3& value)
    Actor::SetRotation(const Matrix& value)
    Actor::SetScale(const Float3& value)
    Actor::SetStaticFlag(StaticFlags flag, bool value)
    Actor::SetStaticFlags(StaticFlags value)
    Actor::SetTransform(const Transform& value)
    CharacterController
    Actor::Tags
    Actor::ToBytes(const Array<Actor* >& actors, MemoryWriteStream& output)
    Actor::ToBytes(const Array<Actor* >& actors)
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    Actor::ToJson()
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    Actor::ToString()
    Actor::TreeExecute(Function<bool(Actor* , Params ...)>& action, Params ... args)
    Actor::TreeExecuteChildren(Function<bool(Actor* , Params ...)>& action, Params ... args)
    PhysicsColliderActor::TriggerEnter
    PhysicsColliderActor::TriggerExit
    Actor::TryGetSerializedObjectsIds(const Span<byte>& data)
    ScriptingObject::UnregisterObject()
    Actor::UnregisterObjectHierarchy()
    Collider::UpdateLayerBits()
    IPhysicsActor::~IPhysicsActor()
    ISerializable::~ISerializable()
    Object::~Object()
    SceneObject::~SceneObject()
    ScriptingObject::~ScriptingObject()
    Assembly: FlaxEngine.dll
    File: Engine/Physics/Colliders/CharacterController.h
    Syntax
    public class CharacterController : public Collider, public IPhysicsActor

    Methods

    AddMovement(const Vector3& translation, const Quaternion& rotation)

    Moves the actor (also can rotate it) in world space.

    Declaration
    public virtual void AddMovement(const Vector3& translation, const Quaternion& rotation) override
    Parameters
    Vector3 translation

    The translation vector.

    Quaternion rotation

    The rotation quaternion.

    Overrides
    Actor::AddMovement(const Vector3& translation, const Quaternion& rotation)

    BeginPlay(SceneBeginData* data)

    Called when adding object to the game.

    Declaration
    protected virtual void BeginPlay(SceneBeginData* data) override
    Parameters
    SceneBeginData data

    The initialization data (e.g. used to collect joints to link after begin).

    Overrides
    Actor::BeginPlay(SceneBeginData* data)

    CanAttach(RigidBody* rigidBody)

    Determines whether this collider can be attached the specified rigid body.

    Declaration
    public virtual bool CanAttach(RigidBody* rigidBody) const override
    Parameters
    RigidBody rigidBody

    The rigid body.

    Returns
    bool

    true if this collider can be attached the specified rigid body; otherwise, false.

    Overrides
    Collider::CanAttach(RigidBody* rigidBody)

    CreateController()

    Creates the physics actor.

    Declaration
    protected void CreateController()

    CreateShape()

    Creates the collider shape.

    Declaration
    public virtual void CreateShape() override
    Overrides
    Collider::CreateShape()

    DeleteController()

    Deletes the physics actor.

    Declaration
    protected void DeleteController()

    DrawPhysicsDebug(RenderView& view)

    Declaration
    protected virtual void DrawPhysicsDebug(RenderView& view) override
    Parameters
    RenderView view

    Overrides
    Collider::DrawPhysicsDebug(RenderView& view)

    EndPlay()

    Called when removing object from the game.

    Declaration
    protected virtual void EndPlay() override
    Overrides
    Actor::EndPlay()

    GetAttachedRigidBody()

    Gets the attached rigid body.

    Declaration
    public virtual RigidBody* GetAttachedRigidBody() const override
    Returns
    RigidBody

    The rigid body or null.

    Overrides
    PhysicsColliderActor::GetAttachedRigidBody()

    GetAutoGravity()

    Gets the automatic gravity force applying mode. Can be toggled off if gameplay controls character movement velocity including gravity, or toggled on if gravity should be applied together with root motion from animation movement.

    Declaration
    public bool GetAutoGravity() const
    Returns
    bool

    GetFlags()

    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
    public CollisionFlags GetFlags() const
    Returns
    CollisionFlags

    GetGeometry(CollisionShape& collision)

    Gets the collider shape geometry.

    Declaration
    protected virtual void GetGeometry(CollisionShape& collision) override
    Parameters
    CollisionShape collision

    The output collision shape.

    Overrides
    Collider::GetGeometry(CollisionShape& collision)

    GetHeight()

    Gets 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
    public float GetHeight() const
    Returns
    float

    GetMinMoveDistance()

    Gets 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
    public float GetMinMoveDistance() const
    Returns
    float

    GetNonWalkableMode()

    Gets the non-walkable mode for the character controller.

    Declaration
    public NonWalkableModes GetNonWalkableMode() const
    Returns
    NonWalkableModes

    GetPhysicsActor()

    Gets the native physics backend object.

    Declaration
    public virtual void* GetPhysicsActor() const override
    Returns
    void

    Overrides
    IPhysicsActor::GetPhysicsActor()

    GetRadius()

    Gets 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
    public float GetRadius() const
    Returns
    float

    GetSlopeLimit()

    Gets the slope limit (in degrees). Limits the collider to only climb slopes that are less steep (in degrees) than the indicated value.

    Declaration
    public float GetSlopeLimit() const
    Returns
    float

    GetStepOffset()

    Gets 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
    public float GetStepOffset() const
    Returns
    float

    GetUpDirection()

    Gets the character up vector.

    Declaration
    public Vector3 GetUpDirection() const
    Returns
    Vector3

    GetVelocity()

    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
    public Vector3 GetVelocity() const
    Returns
    Vector3

    IsGrounded()

    Gets a value indicating whether this character was grounded during last move call grounded.

    Declaration
    public bool IsGrounded() const
    Returns
    bool

    Move(const Vector3& displacement)

    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
    public CollisionFlags Move(const Vector3& displacement)
    Parameters
    Vector3 displacement

    The displacement vector (in world units).

    Returns
    CollisionFlags

    The collision flags. It can be used to trigger various character animations.

    OnActiveInTreeChanged()

    Called when actor active in tree state gets changed.

    Declaration
    protected virtual void OnActiveInTreeChanged() override
    Overrides
    Actor::OnActiveInTreeChanged()

    OnActiveTransformChanged()

    Called when actor's active transformation gets changed after the physics simulation step during.

    This event is called internally by the Physics service and should not be used by the others.

    Declaration
    public virtual void OnActiveTransformChanged() override
    Overrides
    IPhysicsActor::OnActiveTransformChanged()

    OnDebugDrawSelected()

    Draws debug shapes for the selected actor and all child scripts.

    Declaration
    public virtual void OnDebugDrawSelected() override
    Overrides
    Actor::OnDebugDrawSelected()

    OnDisable()

    Called when actor gets removed from game systems. Occurs on EndPlay event or when actor gets inactivated in hierarchy. Use this event to unregister object from other game system (eg. audio).

    Declaration
    protected virtual void OnDisable() override
    Overrides
    Actor::OnDisable()

    OnEnable()

    Called when actor gets added to game systems. Occurs on BeginPlay event or when actor gets activated in hierarchy. Use this event to register object to other game system (eg. audio).

    Declaration
    protected virtual void OnEnable() override
    Overrides
    Actor::OnEnable()

    OnParentChanged()

    Called when actor parent gets changed.

    Declaration
    protected virtual void OnParentChanged() override
    Overrides
    Actor::OnParentChanged()

    OnPhysicsSceneChanged(PhysicsScene* previous)

    Declaration
    protected virtual void OnPhysicsSceneChanged(PhysicsScene* previous) override
    Parameters
    PhysicsScene previous

    Overrides
    Actor::OnPhysicsSceneChanged(PhysicsScene* previous)

    OnTransformChanged()

    Called when actor transform gets changed.

    Declaration
    protected virtual void OnTransformChanged() override
    Overrides
    Actor::OnTransformChanged()

    SetAutoGravity(bool value)

    Sets the automatic gravity force applying mode. Can be toggled off if gameplay controls character movement velocity including gravity, or toggled on if gravity should be applied together with root motion from animation movement.

    Declaration
    public void SetAutoGravity(bool value)
    Parameters
    bool value

    SetHeight(float value)

    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
    public void SetHeight(float value)
    Parameters
    float value

    SetMinMoveDistance(float value)

    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
    public void SetMinMoveDistance(float value)
    Parameters
    float value

    SetNonWalkableMode(NonWalkableModes value)

    Sets the non-walkable mode for the character controller.

    Declaration
    public void SetNonWalkableMode(NonWalkableModes value)
    Parameters
    NonWalkableModes value

    SetRadius(float value)

    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
    public void SetRadius(float value)
    Parameters
    float value

    SetSlopeLimit(float value)

    Sets the slope limit (in degrees). Limits the collider to only climb slopes that are less steep (in degrees) than the indicated value.

    Declaration
    public void SetSlopeLimit(float value)
    Parameters
    float value

    SetStepOffset(float value)

    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
    public void SetStepOffset(float value)
    Parameters
    float value

    SetUpDirection(const Vector3& up)

    Sets the character up vector.

    Declaration
    public void SetUpDirection(const Vector3& up)
    Parameters
    Vector3 up

    SimpleMove(const Vector3& speed)

    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
    public CollisionFlags SimpleMove(const Vector3& speed)
    Parameters
    Vector3 speed

    The movement speed (in units/s).

    Returns
    CollisionFlags

    The collision flags. It can be used to trigger various character animations.

    UpdateBounds()

    Updates the bounding box of the shape.

    Declaration
    public virtual void UpdateBounds() override
    Overrides
    Collider::UpdateBounds()

    UpdateGeometry()

    Updates the shape geometry.

    Declaration
    protected virtual void UpdateGeometry() override
    Overrides
    Collider::UpdateGeometry()

    UpdateSize()

    Updates the character height and radius.

    Declaration
    protected void UpdateSize() const

    See Also

    Collider
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat