Skip to main content

CharacterController

Use CharacterController for collision-aware kinematic movement, grounding, and vertical velocity without implementing a rigid-body solver in Lua.

MethodReturnsDescription
CharacterController.Move(gameObjectId, x, y, z)booleanApplies a movement delta through controller collision.
CharacterController.IsGrounded(gameObjectId)booleanReads grounded state.
CharacterController.GetVelocityY(gameObjectId)numberReads vertical velocity.
CharacterController.SetVelocityY(gameObjectId, velocity)booleanOverrides vertical velocity.
moveSpeed = 3.0
jumpSpeed = 4.5

function Update(gameObjectId, deltaTime)
local moveX, moveY = Input.GetAxis("Move")
CharacterController.Move(
gameObjectId,
moveX * moveSpeed * deltaTime,
0.0,
-moveY * moveSpeed * deltaTime
)

if Input.GetButtonDown("Jump") and CharacterController.IsGrounded(gameObjectId) then
CharacterController.SetVelocityY(gameObjectId, jumpSpeed)
end
end

Movement may be constrained by Colliders, Step Offset, Slope Limit, and Skin Width. Ground and slope tests sample the upper plane of supported rotated box Colliders. This is Character Controller surface handling, not general rigid-body OBB physics. Moving-platform velocity, coyote time, and gameplay-specific jump buffering must be implemented by the project when required.

The example requires a Character Controller on the host and a Jump Button action in Project Settings > Input Action Map. Avoid running this custom movement alongside a native Player Motor on the same object, which would apply movement twice. The engine does not create a Jump action merely because a script names it.