Skip to content

Character Controller

App: apps/character_controller/

A top-down 3D character controller demo. The character capsule is driven by CharacterController (Jolt CharacterVirtual). The controller handles ground detection, stair-stepping, and slope response automatically. Physics bodies (floor and optional obstacles) are created in code — no .blend required.

Terminal window
% ./plume3d character_controller
KeyAction
WASD / Arrow keysMove
ShiftRun
SpaceJump (when grounded)
CToggle crouch
EInteract (one-shot animation demo)
1Toggle instrument out/in (custom state demo)
MouseRotate character to face mouse position
  • Creates a CharacterController in code via Scene.createCharacterController(1.8, 0.3, 0, 2, 0).
  • Sets speed properties: walkSpeed = 3, runSpeed = 7, crouchSpeed = 1.5, jumpVelocity = 6.
  • Creates a static box floor with Physics.addStaticBox.
  • Binds the controller to a scene node (controller.node = _charNode) so the node’s position follows the physics capsule each frame.
  • Reads controller.state and logs state transitions (Idle → Walking → Running → Jumping → Falling, etc.).
  • Demonstrates all CharacterState constants in a top-down camera setup.
  • Shadow mapping enabled: light.castsShadows = true + Graphics.setShadowMappingEnabled(true).
// Create controller
_controller = _scene.createCharacterController(1.8, 0.3, 0, 2, 0)
_controller.walkSpeed = 3.0
_controller.runSpeed = 7.0
_controller.jumpVelocity = 6.0
_controller.node = _charNode
// Movement input (in update)
var moveX = 0
var moveZ = 0
if (Input.key("w")) moveZ = moveZ - 1
if (Input.key("s")) moveZ = moveZ + 1
if (Input.key("a")) moveX = moveX - 1
if (Input.key("d")) moveX = moveX + 1
_controller.running = Input.modShift()
_controller.crouching = Input.key("c")
_controller.setDesiredVelocity(moveX * speed, 0, moveZ * speed)
if (Input.keyJustPressed("space") && _controller.isGrounded) {
_controller.jump()
}
// Read state
if (_controller.state != _lastState) {
Logger.info("State: %(_stateNames[_controller.state])")
_lastState = _controller.state
}
  • CharacterControllercreateCharacterController, setDesiredVelocity, jump, running=, crouching=, isGrounded, state, node=, speed properties.
  • CharacterStateIDLE, WALKING, RUNNING, JUMPING, FALLING, CROUCHING, INTERACTING, etc.
  • PhysicsaddStaticBox, setGravity.
  • GraphicssetLights, setShadowMappingEnabled.
  • LightcastsShadows.
  • Scene, Node, Camera.