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
    System.Object
    Object
    SceneObject
    Actor
    PhysicsColliderActor
    Collider
    CharacterController
    Implements
    ISerializable
    Inherited Members
    Collider.ComputePenetration(Collider, Collider, Vector3, Single)
    Collider.Material
    Collider.IsTrigger
    Collider.Center
    Collider.ContactOffset
    PhysicsColliderActor.RayCast(Vector3, Vector3, Single, Single)
    PhysicsColliderActor.RayCast(Vector3, Vector3, RayCastHit, Single)
    PhysicsColliderActor.ClosestPoint(Vector3, Vector3)
    PhysicsColliderActor.ContainsPoint(Vector3)
    PhysicsColliderActor.OnCollisionEnter(Collision)
    PhysicsColliderActor.OnCollisionExit(Collision)
    PhysicsColliderActor.OnTriggerEnter(PhysicsColliderActor)
    PhysicsColliderActor.OnTriggerExit(PhysicsColliderActor)
    PhysicsColliderActor.AttachedRigidBody
    PhysicsColliderActor.CollisionEnter
    PhysicsColliderActor.CollisionExit
    PhysicsColliderActor.TriggerEnter
    PhysicsColliderActor.TriggerExit
    Actor.SetLayerRecursive(Int32)
    Actor.SetLayerNameRecursive(String)
    Actor.HasTag()
    Actor.HasTag(Tag)
    Actor.HasTag(String)
    Actor.AddTag(Tag)
    Actor.AddTagRecursive(Tag)
    Actor.RemoveTag(Tag)
    Actor.SetParent(Actor, Boolean, Boolean)
    Actor.GetChild(Int32)
    Actor.GetChild(String)
    Actor.GetChild(Type)
    Actor.GetChildren(Type)
    Actor.DestroyChildren(Single)
    Actor.GetScript(Int32)
    Actor.GetScript(Type)
    Actor.GetScripts(Type)
    Actor.AddMovement(Vector3)
    Actor.AddMovement(Vector3, Quaternion)
    Actor.GetWorldToLocalMatrix(Matrix)
    Actor.GetLocalToWorldMatrix(Matrix)
    Actor.OnDebugDraw()
    Actor.OnDebugDrawSelected()
    Actor.GetPrefabRoot()
    Actor.FindActor(String)
    Actor.FindActor(Type, Boolean)
    Actor.FindActor(Type, String)
    Actor.FindActor(Type, Tag, Boolean)
    Actor.FindScript(Type)
    Actor.HasActorInHierarchy(Actor)
    Actor.HasActorInChildren(Actor)
    Actor.IntersectsItself(Ray, Single, Vector3)
    Actor.Intersects(Ray, Single, Vector3)
    Actor.LookAt(Vector3)
    Actor.LookAt(Vector3, Vector3)
    Actor.LookingAt(Vector3)
    Actor.LookingAt(Vector3, Vector3)
    Actor.ToBytes(Actor[])
    Actor.FromBytes(Byte[])
    Actor.FromBytes(Byte[], Dictionary<Guid, Guid>)
    Actor.TryGetSerializedObjectsIds(Byte[])
    Actor.ToJson()
    Actor.FromJson(String)
    Actor.Clone()
    Actor.OnEnable()
    Actor.OnDisable()
    Actor.OnParentChanged()
    Actor.OnTransformChanged()
    Actor.OnActiveChanged()
    Actor.OnActiveInTreeChanged()
    Actor.OnOrderInParentChanged()
    Actor.OnStaticFlagsChanged()
    Actor.OnLayerChanged()
    Actor.OnBeginPlay()
    Actor.OnEndPlay()
    Actor.AddStaticFlags(StaticFlags)
    Actor.RemoveStaticFlags(StaticFlags)
    Actor.SetStaticFlag(StaticFlags, Boolean)
    Actor.HasStaticFlag(StaticFlags)
    Actor.ResetLocalTransform()
    Actor.AddChild(Type)
    Actor.AddChild<T>()
    Actor.GetChild<T>()
    Actor.TryGetChild<T>(T)
    Actor.GetOrAddChild<T>()
    Actor.AddScript(Type)
    Actor.AddScript<T>()
    Actor.GetScript<T>()
    Actor.TryGetScript<T>(T)
    Actor.FindScript<T>()
    Actor.FindActor<T>(Boolean)
    Actor.FindActor<T>(String)
    Actor.FindActor<T>(Tag, Boolean)
    Actor.GetChildren<T>()
    Actor.GetScripts<T>()
    Actor.RotateAround(Vector3, Vector3, Single, Boolean)
    Actor.ToString()
    Actor.Children
    Actor.Tags
    Actor.Layer
    Actor.Name
    Actor.IsActive
    Actor.StaticFlags
    Actor.PerInstanceRandom
    Actor.LocalPosition
    Actor.LocalOrientation
    Actor.LocalScale
    Actor.Sphere
    Actor.Box
    Actor.BoxWithChildren
    Actor.EditorBox
    Actor.EditorBoxChildren
    Actor.HasContentLoaded
    Actor.IsPrefabRoot
    Actor.IsStatic
    Actor.IsTransformStatic
    Actor.WorldToLocalMatrix
    Actor.LocalToWorldMatrix
    SceneObject.SetParent(Actor, Boolean)
    SceneObject.LinkPrefab(Guid, Guid)
    SceneObject.BreakPrefabLink()
    SceneObject.GetNamePath(Char)
    SceneObject.IsDuringPlay
    SceneObject.HasParent
    SceneObject.HasPrefabLink
    SceneObject.PrefabID
    SceneObject.PrefabObjectID
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [ActorContextMenu("New/Physics/Character Controller")]
    [ActorToolbox("Physics")]
    [Unmanaged]
    public class CharacterController : Collider, ISerializable

    Constructors

    CharacterController()

    Initializes a new instance of the CharacterController.

    Declaration
    public CharacterController()

    Properties

    AutoGravity

    Gets or 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
    [EditorOrder(250)]
    [EditorDisplay("Character Controller", null)]
    [Unmanaged]
    public bool AutoGravity { get; set; }
    Property Value
    System.Boolean

    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.

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)

    See Also

    Collider
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat