CharacterController

Component representing a physics capsule and implementing standard character motion.

Summary
CharacterControllerComponent representing a physics capsule and implementing standard character motion.
Functions
MoveForwardMoves the capsule forward along its heading.
MoveBackwardMoves the capsule backward opposite its heading.
MoveLeftMoves the capsule left relative to its heading.
MoveRightMoves the capsule right relative to its heading.
MoveUpMoves the capsule up.
MoveDownMoves the capsule down.
GetPhiReturns the phi rotation of the controller.
GetThetaReturns the theta rotation of the controller.
GetSpeedGet the current magnitude of the controller’s velocity
SetFallSpeedSets the maxiumum allowed fall speed for this controller
SetGravitySets the gravity that acts on the controller [Default] <0.0, -16.0, 0.0>
NKSetDefaultGravityResets the gravity to the global default [Default] <0.0, -16.0, 0.0>
NKSetPhiSets the angle of rotation on the Y Z plane (around the x axis)
NKSetThetaSets the angle of rotation on the X Z plane (around the y axis)
SetCanJumpSets a flag that determines if this controller can jump or not
SetCanFlySets if the controller can activate flying mode
JumpTells the controller to initiate a jump next frame.
EnableFlyingTurns on fly mode for the controller.
DisableFlyingTurns off fly mode for the controller.
NKGetJumpFlagReturns whether or not this controller is currently in the jumping state.
StepCommits all of the requested movement and changes for the next frame.
OnGround (Use NKOnGround)Checks to see if the controller is on the ground.
NKIsMovingReturns whether or not the controller is moving.
NKOnGroundChecks to see if the controller is on the ground.
NKSetMaxSpeedChecks to see if the controller is on the ground.
NKGetMaxSpeedChecks to see if the controller is on the ground.
NKGetStateGets the controller’s current enumerated state
NKSwitchToEntityControllerSets the controller to an entity, non-player, controller.
NKEnableEventsNo longer supported.
NKDisableEventsNo longer supported.
NKEnableContactEventsNo longer supported.
NKEnableTriggerEventsNo longer supported.
NKEnableOnLeaveBroadphaseEventsNo longer supported.
NKSetStrength(PROXY CONTROLLERS ONLY) The maximum constant force that the character controller can impart onto dynamic objects.
NKGetStrength(PROXY CONTROLLERS ONLY) Returns the strength of the controller
NKSetMassUsed in both the proxy controller and rigidobdy controller implementations.
NKGetMassReturns the mass of the controller.
NKSetMaxPushForceSets the maxiumum force that this controller can apply to non-controller dynamic bodies.
NKGetMaxPushForceReturns the max psuhing force of the controller.
NKSetTraceableSet if the controller can be traced by physics queries.
NKSetAlignWithCameraSet if the controller’s orientation should align with the camera’s forward direction.
NKApplyImpulseApply an impulse to the controller.
NKSetEnableSets if the controller is enabled.
NKSetLayerSets the physics collision layer
NKEnableSimulationAdds the controller to the simulation.
NKDisableSimulationRemoves the controller from the simulation.
NKGetLinearVelocityReturns the linear velocity of this controller.
NKGetMovementDirectionReturns the vector that holds the pressed move directions for this frame.

Functions

MoveForward

Moves the capsule forward along its heading.

MoveBackward

Moves the capsule backward opposite its heading.

MoveLeft

Moves the capsule left relative to its heading.

MoveRight

Moves the capsule right relative to its heading.

MoveUp

Moves the capsule up.

MoveDown

Moves the capsule down.

GetPhi

Returns the phi rotation of the controller.

Returns

floatThe phi rotation of the controller.

GetTheta

Returns the theta rotation of the controller.

Returns

floatThe theta rotation of the controller.

GetSpeed

Get the current magnitude of the controller’s velocity

SetFallSpeed

Sets the maxiumum allowed fall speed for this controller

SetGravity

Sets the gravity that acts on the controller [Default] <0.0, -16.0, 0.0>

NKSetDefaultGravity

Resets the gravity to the global default [Default] <0.0, -16.0, 0.0>

NKSetPhi

Sets the angle of rotation on the Y Z plane (around the x axis)

Parameters

floatthe phi value in radians

NKSetTheta

Sets the angle of rotation on the X Z plane (around the y axis)

Parameters

floatthe theta value in radians

SetCanJump

Sets a flag that determines if this controller can jump or not

Parameters

boola boolean flag

SetCanFly

Sets if the controller can activate flying mode

Parameters

boola boolean flag

Jump

Tells the controller to initiate a jump next frame.

EnableFlying

Turns on fly mode for the controller.

DisableFlying

Turns off fly mode for the controller.

NKGetJumpFlag

Returns whether or not this controller is currently in the jumping state.

Returns

boolWhether or not this controller is currently in the jumping state.

Step

Commits all of the requested movement and changes for the next frame.

OnGround (Use NKOnGround)

Checks to see if the controller is on the ground.

Returns

boolReturns true if capsule is on ground.

NKIsMoving

Returns whether or not the controller is moving.

Returns

boolreturns true if the controller is moving

NKOnGround

Checks to see if the controller is on the ground.

Returns

boolReturns true if capsule is on ground.

NKSetMaxSpeed

Checks to see if the controller is on the ground.

Parameters

floatthe maxiumum speed the controller can move
bool(optional, default: true) Network Hard Set - true to force the network to hard set this value, false to only take the most up to date data (false if you are changing this value a lot for a character controller each frame)

NKGetMaxSpeed

Checks to see if the controller is on the ground.

Parameters

floatthe maxiumum speed the controller can move

NKGetState

Gets the controller’s current enumerated state

Returns

CharacterController::CharacterStateThe enumerated state.  See controllet state enumerations

NKSwitchToEntityController

Sets the controller to an entity, non-player, controller.

Parameters

intUNUSED

NKEnableEvents

No longer supported.

NKDisableEvents

No longer supported.

NKEnableContactEvents

No longer supported.

NKEnableTriggerEvents

No longer supported.

NKEnableOnLeaveBroadphaseEvents

No longer supported.

NKSetStrength

(PROXY CONTROLLERS ONLY) The maximum constant force that the character controller can impart onto dynamic objects.  By default this is HK_REAL_MAX, i.e., the character controller is infinitely strong. default(7.9E+28f) absmin=0, absmax=7.9E+28

Paramaters

floatThe strength

NKGetStrength

(PROXY CONTROLLERS ONLY) Returns the strength of the controller

Returns

floatThe strength

NKSetMass

Used in both the proxy controller and rigidobdy controller implementations.  Proxy: The mass of the character.  This value is only used to apply an extra downward force to dynamic rigid bodies that the character is standing on.  By default this value is 0, which means no additional downward force is applied.  It should only be set to a positive value if you do not apply gravity from your state machine when the character is on the ground. default(0) absmin=0.0 absmax=1000.0 Rigidbody: The mass of character. default(100.0f) absmin=0.0, absmax=1000.0

Paramaters

floatThe mass

NKGetMass

Returns the mass of the controller.

Returns

floatThe mass

NKSetMaxPushForce

Sets the maxiumum force that this controller can apply to non-controller dynamic bodies. default(1000.0f) absmin=0.0, absmax=100000.0

Paramaters

floatThe max pushing force

NKGetMaxPushForce

Returns the max psuhing force of the controller.

Returns

floatThe pushing force.

NKSetTraceable

Set if the controller can be traced by physics queries.

Parameters

Booleanenable / disable

NKSetAlignWithCamera

Set if the controller’s orientation should align with the camera’s forward direction.  (Player only)

Parameters

Booleanenable / disable

NKApplyImpulse

Apply an impulse to the controller.  The provided impulse vector’s normal is the direction and the magnitude is the amount.

Parameters

vec3Impulse vector

NKSetEnable

Sets if the controller is enabled.  Enabled will have the controller be ticked by the simulation and disabled will not.

Parameters

Booleanenable / disable

NKSetLayer

Sets the physics collision layer

NKEnableSimulation

Adds the controller to the simulation.

NKDisableSimulation

Removes the controller from the simulation.

NKGetLinearVelocity

Returns the linear velocity of this controller.

Returns

vec3The linear velocity of this controller.

NKGetMovementDirection

Returns the vector that holds the pressed move directions for this frame.  Note that once Step has been called on this controller, this value will be set to (0,0,0) until input is read on the next frame.

Returns

vec3The vector representing the move direction read from input.
Close