⮞ Go to NeoFPS.com

    Show / Hide Table of Contents

    Interface INeoCharacterController

    INeoCharacterController is a character controller, which handles kinematic character movement and collision resolution within a scene.

    Namespace: NeoCC
    Assembly: NeoFPS.dll
    Syntax
    public interface INeoCharacterController

    Properties

    airTime

    The amount of time the controller has been airborne without a ground contact.

    Declaration
    float airTime { get; }
    Property Value
    Type Description
    System.Single

    characterCollisionHandler

    A callback that is used by the character to resolve collisions with other INeoCharacterController characters. The character should implement and expose a default handler.

    Declaration
    NeoCharacterControllerDelegates.OnHitCharacter characterCollisionHandler { get; set; }
    Property Value
    Type Description
    NeoCharacterControllerDelegates.OnHitCharacter

    characterGravity

    The variable gravity setup for this character if applicable.

    Declaration
    INeoCharacterVariableGravity characterGravity { get; }
    Property Value
    Type Description
    INeoCharacterVariableGravity

    collisionFlags

    The collision flags for detecting scene collisions while moving.

    Declaration
    NeoCharacterCollisionFlags collisionFlags { get; }
    Property Value
    Type Description
    NeoCharacterCollisionFlags

    collisionMask

    The collision layers the controller will collide with when moving.

    Declaration
    LayerMask collisionMask { get; set; }
    Property Value
    Type Description
    LayerMask

    collisionsEnabled

    Should the character collide with scene colliders (static or otherwise). Defaults to true.

    Declaration
    bool collisionsEnabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    debugDepenetrationCount

    Declaration
    int debugDepenetrationCount { get; }
    Property Value
    Type Description
    System.Int32

    debugExternalForceMove

    Declaration
    Vector3 debugExternalForceMove { get; }
    Property Value
    Type Description
    Vector3

    debugMoveIterations

    Declaration
    int debugMoveIterations { get; }
    Property Value
    Type Description
    System.Int32

    debugSnapToGround

    Declaration
    bool debugSnapToGround { get; }
    Property Value
    Type Description
    System.Boolean

    depenetrationMask

    The collision layers the controller will depenetrate from. Use this to prevent small rigidbodies from causing the character to move out of the way

    Declaration
    LayerMask depenetrationMask { get; set; }
    Property Value
    Type Description
    LayerMask

    enabled

    Declaration
    bool enabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    forward

    The forward axis of the controller in world space.

    Declaration
    Vector3 forward { get; }
    Property Value
    Type Description
    Vector3

    gravity

    The gravity vector applied to this character.

    Declaration
    Vector3 gravity { get; }
    Property Value
    Type Description
    Vector3

    groundNormal

    The normal of the last ground contact.

    Declaration
    Vector3 groundNormal { get; }
    Property Value
    Type Description
    Vector3

    groundSnapHeight

    The height below which the character controller should snap to the ground.

    Declaration
    float groundSnapHeight { get; set; }
    Property Value
    Type Description
    System.Single

    groundSurfaceNormal

    The normal of the ground surface for the last contact. If the controller is on a ledge, this is the top surface of the ledge.

    Declaration
    Vector3 groundSurfaceNormal { get; }
    Property Value
    Type Description
    Vector3

    height

    The height of the character capsule.

    Declaration
    float height { get; set; }
    Property Value
    Type Description
    System.Single

    ignoreExternalForces

    If this is true, any forces applied with AddForce() will be ignored. Defaults to false.

    Declaration
    bool ignoreExternalForces { get; set; }
    Property Value
    Type Description
    System.Boolean

    ignorePlatforms

    Should the character move with platforms it's in contact with. Defaults to false.

    Declaration
    bool ignorePlatforms { get; set; }
    Property Value
    Type Description
    System.Boolean

    inheritPlatformYaw

    Should the character inherit yaw rotation from moving platforms? Defaults to true.

    Declaration
    bool inheritPlatformYaw { get; set; }
    Property Value
    Type Description
    System.Boolean

    isGrounded

    Is the character in contact with a ground surface.

    Declaration
    bool isGrounded { get; }
    Property Value
    Type Description
    System.Boolean

    lastFrameMove

    The move vector from the last fixed update move.

    Declaration
    Vector3 lastFrameMove { get; }
    Property Value
    Type Description
    Vector3

    ledgeFriction

    The friction of ground contacts when the controller is overhanging a ledge. At 1, the character will not slide off the ledge.

    Declaration
    float ledgeFriction { get; set; }
    Property Value
    Type Description
    System.Single

    mass

    The mass of the character.

    Declaration
    float mass { get; set; }
    Property Value
    Type Description
    System.Single

    platform

    The platform the character is currently affected by.

    Declaration
    IMovingPlatform platform { get; }
    Property Value
    Type Description
    IMovingPlatform

    pushCharacters

    Should the character push other character controllers. Defaults to true.

    Declaration
    bool pushCharacters { get; set; }
    Property Value
    Type Description
    System.Boolean

    pushedByCharacters

    Can the character be pushed by other character controllers. Defaults to true.

    Declaration
    bool pushedByCharacters { get; set; }
    Property Value
    Type Description
    System.Boolean

    pushRigidbodies

    Should the character push dynamic rigidbodies. Defaults to true.

    Declaration
    bool pushRigidbodies { get; set; }
    Property Value
    Type Description
    System.Boolean

    radius

    The radius of the character capsule.

    Declaration
    float radius { get; set; }
    Property Value
    Type Description
    System.Single

    rawVelocity

    The actual velocity of the character during the last move phase with no modifications applied.

    Declaration
    Vector3 rawVelocity { get; }
    Property Value
    Type Description
    Vector3

    right

    The right axis of the controller in world space.

    Declaration
    Vector3 right { get; }
    Property Value
    Type Description
    Vector3

    rigidbodyCollisionHandler

    A callback that is used by the character to resolve collisions with dynamic rigidbodies. The character should implement and expose a default handler.

    Declaration
    NeoCharacterControllerDelegates.OnHitRigidbody rigidbodyCollisionHandler { get; set; }
    Property Value
    Type Description
    NeoCharacterControllerDelegates.OnHitRigidbody

    skinWidth

    When performing the move loop, the capsule is shrunk by this amount. When testing for contacts it is grown by this amount.

    Declaration
    float skinWidth { get; set; }
    Property Value
    Type Description
    System.Single

    slopeFriction

    The friction of ground contacts when standiong on a slope. At 1, all downward velocity will be cancelled out. At 0, the character will slide down the slope.

    Declaration
    float slopeFriction { get; set; }
    Property Value
    Type Description
    System.Single

    slopeLimit

    The maximum upwards slope the character can climb. Any horizontal movement into the slope will not become vertical movement above this angle.

    Declaration
    float slopeLimit { get; set; }
    Property Value
    Type Description
    System.Single

    stepHeight

    The character will step up onto ledges with this height without losing horizontal speed. The upward movement will not be factored into the character velocity at the end of the move.

    Declaration
    float stepHeight { get; set; }
    Property Value
    Type Description
    System.Single

    targetVelocity

    The velocity from the character input during the last move phase, before collision response was calculated.

    Declaration
    Vector3 targetVelocity { get; }
    Property Value
    Type Description
    Vector3

    transform

    Declaration
    Transform transform { get; }
    Property Value
    Type Description
    Transform

    up

    The up axis for the controller in world space.

    Declaration
    Vector3 up { get; }
    Property Value
    Type Description
    Vector3

    velocity

    The velocity of the character during the last move phase with some corrections such as ignoring the vertical movement of steps.

    Declaration
    Vector3 velocity { get; }
    Property Value
    Type Description
    Vector3

    wallAngle

    The maximum angle from vertical where a surface is classed as a wall.

    Declaration
    float wallAngle { get; }
    Property Value
    Type Description
    System.Single

    Methods

    AddForce(Vector3, ForceMode, Boolean)

    Add a force to the character outside of the usual movement logic (eg. explosions, etc)

    Declaration
    void AddForce(Vector3 force, ForceMode mode = null, bool disableGroundSnapping = false)
    Parameters
    Type Name Description
    Vector3 force

    Force vector in world coordinates.

    ForceMode mode

    Type of force to apply. See the Unity Scripting Reference.

    System.Boolean disableGroundSnapping

    AddPositionOffset(Vector3)

    Add a position offset to the next movement tick

    Declaration
    void AddPositionOffset(Vector3 offset)
    Parameters
    Type Name Description
    Vector3 offset

    AddYawOffset(Single)

    Add a yaw rotation offset to the next movement tick

    Declaration
    void AddYawOffset(float yaw)
    Parameters
    Type Name Description
    System.Single yaw

    CancelHeightChange()

    Cancel any delayed height change and keep the current height.

    Declaration
    void CancelHeightChange()

    CapsuleCast(Vector3, Space, out RaycastHit, Int32, QueryTriggerInteraction)

    Declaration
    bool CapsuleCast(Vector3 castVector, Space space, out RaycastHit hit, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = null)
    Parameters
    Type Name Description
    Vector3 castVector
    Space space
    RaycastHit hit
    System.Int32 layerMask
    QueryTriggerInteraction queryTriggerInteraction
    Returns
    Type Description
    System.Boolean

    CapsuleCast(Vector3, Space, Int32)

    Declaration
    bool CapsuleCast(Vector3 castVector, Space space, int layerMask = -5)
    Parameters
    Type Name Description
    Vector3 castVector
    Space space
    System.Int32 layerMask
    Returns
    Type Description
    System.Boolean

    GetComponent<T>()

    Declaration
    T GetComponent<T>()
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    Initialise()

    A manual initialisation function to prevent issues with script execution order

    Declaration
    void Initialise()

    IsHeightRestricted(Single)

    Check if the character has space to change its height to the specified value without overlapping the environment.

    Declaration
    bool IsHeightRestricted(float h)
    Parameters
    Type Name Description
    System.Single h

    The target height. The height can not be smaller than double the radius.

    Returns
    Type Description
    System.Boolean

    Can the character expand or not.

    RayCast(Single, Vector3, Space, out RaycastHit, Int32, QueryTriggerInteraction)

    Declaration
    bool RayCast(float normalisedHeight, Vector3 castVector, Space space, out RaycastHit hit, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = null)
    Parameters
    Type Name Description
    System.Single normalisedHeight
    Vector3 castVector
    Space space
    RaycastHit hit
    System.Int32 layerMask
    QueryTriggerInteraction queryTriggerInteraction
    Returns
    Type Description
    System.Boolean

    RayCast(Single, Vector3, Space, Int32)

    Declaration
    bool RayCast(float normalisedHeight, Vector3 castVector, Space space, int layerMask = -5)
    Parameters
    Type Name Description
    System.Single normalisedHeight
    Vector3 castVector
    Space space
    System.Int32 layerMask
    Returns
    Type Description
    System.Boolean

    ResetHeight(Single)

    Reset the character capsule height to its value upon start. If the character height is restricted, it will keep trying until it has space to resize, or the height change is cancelled.

    Declaration
    void ResetHeight(float fromNormalisedHeight = 0F)
    Parameters
    Type Name Description
    System.Single fromNormalisedHeight

    The point to resize from. 0 is the bottom of the current capsule, and 1 is the top.

    ResetHorizontalVelocity()

    Reset the horizontal component of all velocity variables to zero

    Declaration
    void ResetHorizontalVelocity()

    ResetRadius()

    Reset the character capsule radius to its value upon start. If the resulting capsule would overlap the environment then the controller will keep trying until there is space for the capsule to be resized.

    Declaration
    void ResetRadius()

    ResetVelocity()

    Reset all velocity variables to zero

    Declaration
    void ResetVelocity()

    ResetVerticalVelocity()

    Reset the vertical component of all velocity variables to zero

    Declaration
    void ResetVerticalVelocity()

    SetHeight(Single, Single)

    Set the height of the character to a specific value. The height can not be smaller than double the radius. If the resulting capsule would overlap the environment then the controller will keep trying until there is space for the capsule to be resized.

    Declaration
    void SetHeight(float h, float fromNormalisedHeight = 0F)
    Parameters
    Type Name Description
    System.Single h

    The target height.

    System.Single fromNormalisedHeight

    The point to resize from. 0 is the bottom of the current capsule, and 1 is the top.

    SetMoveCallback(NeoCharacterControllerDelegates.GetMoveVector, NeoCharacterControllerDelegates.OnMoved)

    Attach input callbacks to the character controller. The controller movement needs to occur in a specific sequence, and so will request input when required.

    Declaration
    void SetMoveCallback(NeoCharacterControllerDelegates.GetMoveVector moveCallback, NeoCharacterControllerDelegates.OnMoved onMovedCallback)
    Parameters
    Type Name Description
    NeoCharacterControllerDelegates.GetMoveVector moveCallback

    A callback for the character move, called each fixed update.

    NeoCharacterControllerDelegates.OnMoved onMovedCallback

    SetRadius(Single)

    Set the radius of the character to a specific value. If the resulting capsule would overlap the environment then the controller will keep trying until there is space for the capsule to be resized.

    Declaration
    void SetRadius(float r)
    Parameters
    Type Name Description
    System.Single r

    The target radius.

    SetVelocity(Vector3)

    Set all velocity variables to a specific vector

    Declaration
    void SetVelocity(Vector3 v)
    Parameters
    Type Name Description
    Vector3 v

    SphereCast(Single, Vector3, Space, out RaycastHit, Int32, QueryTriggerInteraction)

    Declaration
    bool SphereCast(float normalisedHeight, Vector3 castVector, Space space, out RaycastHit hit, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = null)
    Parameters
    Type Name Description
    System.Single normalisedHeight
    Vector3 castVector
    Space space
    RaycastHit hit
    System.Int32 layerMask
    QueryTriggerInteraction queryTriggerInteraction
    Returns
    Type Description
    System.Boolean

    SphereCast(Single, Vector3, Space, Int32)

    Declaration
    bool SphereCast(float normalisedHeight, Vector3 castVector, Space space, int layerMask = -5)
    Parameters
    Type Name Description
    System.Single normalisedHeight
    Vector3 castVector
    Space space
    System.Int32 layerMask
    Returns
    Type Description
    System.Boolean

    Teleport(Vector3, Quaternion, Boolean, Boolean)

    Move to the new position and rotation. Updates velocity and properties to match new frame of reference

    Declaration
    void Teleport(Vector3 position, Quaternion rotation, bool relativeRotation = true, bool ignoreTilt = false)
    Parameters
    Type Name Description
    Vector3 position

    The position the character should move to.

    Quaternion rotation

    The new rotation for the character.

    System.Boolean relativeRotation

    Is the rotation parameter relative to the current rotation or absolute?

    System.Boolean ignoreTilt

    Should the teleport rotation be modified to maintain the character's up vector?

    TryResetHeight(Single)

    Try to reset the character capsule height to its value upon start. If the character height is restricted by the environment, then the character height will not be changed.

    Declaration
    bool TryResetHeight(float fromNormalisedHeight = 0F)
    Parameters
    Type Name Description
    System.Single fromNormalisedHeight

    The point to resize from. 0 is the bottom of the current capsule, and 1 is the top.

    Returns
    Type Description
    System.Boolean

    Did the character height change (true), or was it restricted (false).

    TryResetRadius()

    Try to reset the character capsule radius to its value upon start. If the resulting capsule would overlap the environment then the character capsule will not be changed.

    Declaration
    bool TryResetRadius()
    Returns
    Type Description
    System.Boolean

    Did the character radius change (true), or was it restricted (false).

    TrySetHeight(Single, Single)

    Try to set the character capsule height to a specific value. The height can not be smaller than double the radius. If the character height is restricted by the environment, then the character height will not be changed.

    Declaration
    bool TrySetHeight(float h, float fromNormalisedHeight = 0F)
    Parameters
    Type Name Description
    System.Single h

    The target height.

    System.Single fromNormalisedHeight

    The point to resize from. 0 is the bottom of the current capsule, and 1 is the top.

    Returns
    Type Description
    System.Boolean

    Did the character height change (true), or was it restricted (false).

    TrySetRadius(Single)

    Try to reset the character capsule radius to its value upon start. If the resulting capsule would overlap the environment then the character capsule will not be changed.

    Declaration
    bool TrySetRadius(float r)
    Parameters
    Type Name Description
    System.Single r

    The target radius.

    Returns
    Type Description
    System.Boolean

    Did the character radius change (true), or was it restricted (false).

    Events

    onControllerHit

    An event fired when the character collides with an obstacle while calculating its move. Not all collisions fire an event. For example, colliding with a step and stepping up is handled silently.

    Declaration
    event NeoCharacterControllerDelegates.OnCharacterControllerHit onControllerHit
    Event Type
    Type Description
    NeoCharacterControllerDelegates.OnCharacterControllerHit

    onHeightChanged

    An event that is fired when the character changes height. If the character height is restricted, then a height change will be delayed until the character has space to resize.

    Declaration
    event NeoCharacterControllerDelegates.OnHeightChange onHeightChanged
    Event Type
    Type Description
    NeoCharacterControllerDelegates.OnHeightChange

    onTeleported

    An event fired when the character is teleported to a new position.

    Declaration
    event NeoCharacterControllerDelegates.OnTeleported onTeleported
    Event Type
    Type Description
    NeoCharacterControllerDelegates.OnTeleported
    Back to top Copyright © 2019 Yondernauts Game Studios Ltd
    Generated with DocFX