DatumHueEnterprise v0.0.24datumhue.com
Contents

handle3 methods, 10 fields

CharacterController

A kinematic character controller bound to a body, created by body:character_controller{...}. It solves collide-and-slide geometry (walls, slopes, stairs, ground-snap); gravity, jump, input, and camera stay in your code. The solver knobs are read/write properties; move is a pure query you apply yourself.

Obtained from
SceneNode:character_controller, DrawPrimitive:character_controller

The examples on this page start from:

lua
local vec2 = datumhue.math.vec2
local canvas =
    datumhue.draw.new({ background = datumhue.color("#2d353b") })
canvas:mount({ width = 400, height = 300 })
-- A kinematic body moves only where it is put.
local hero = canvas:rect({ width = 20, height = 40 })
hero:add_body({ type = "kinematic" })
local controller = hero:character_controller()

Fields 10

FieldTypeAccessDescription
upVec3read/writeFloor-defining up direction (unit vector). Selects which contacts count as ground and is the slope-angle reference. Assign a vec2/vec3; 2D uses the XY components.
offsetnumber | physics.RelativeLengthread/writeSmall gap kept between the character and surroundings for numerical stability; must be > 0.
slidebooleanread/writeSlide along blocking walls instead of stopping dead.
max_slope_climb_anglenumberread/writeSteepest slope, in radians, the character climbs; steeper surfaces act as walls.
min_slope_slide_anglenumberread/writeSlope angle, in radians, at/above which the character auto-slides down.
snap_to_groundnumber | physics.RelativeLength | booleanread/writeDistance to snap down onto ground after a move; false when disabled.
autostepphysics.AutostepConfig | booleanread/writeStep-climbing config, or false when disabled. Assign a config table to enable. Needs a flat-bottomed body (cube or cylinder): the step lands the body on the ledge by only the frame's leftover motion, and a capsule's rounded bottom slides back off. The body also needs head room of its own height plus max_height above where it stands, so a low ceiling stops it stepping.
Example
-- Climb steps up to 12 units high, onto ledges at least half
-- its width.
controller.autostep =
    { max_height = 12, min_width = { relative = 0.5 } }
print(controller.autostep.max_height) --> 12.0
-- false turns stepping off again.
controller.autostep = false
normal_nudge_factornumberread/writeTiny anti-stick push along contact normals while sliding, 0 to 1.
groundedbooleanread-onlyResult of the last move: standing on ground afterward. False while that move commanded upward motion (e.g. a jump), so a launching jump is never reported grounded, and false before the first move.
sliding_down_slopebooleanread-onlyResult of the last move: the character was let slide down a too-steep slope. False before the first move.

Methods 3

CharacterController:move

method
CharacterController:move(displacement: Vec2 | Vec3, dt?: number) -> physics.CharacterMove

Sweep the character by displacement and return the movement actually allowed plus the grounded/slope results and the surfaces hit. Does NOT move the body — apply it yourself (body.pos = body.pos + result.translation). displacement and translation are in the frame of the body's pos: relative to its parent for a nested body, so a character inside a scaled or turned group moves in the group's units and directions; up and the collision points and normals stay in world space. displacement is the full movement you want this frame, each component at most 1000000, and must already include your own gravity·dt and jump velocity; the controller adds no gravity. For correct stair-climbing under gravity, you may move horizontal and vertical displacement in separate calls. dt (seconds, > 0) is the solver timestep used only for moving-platform carry; it defaults to the fixed timestep and does NOT scale displacement (you already scaled that by your frame time).

Example
local floor =
    canvas:rect({ pos = vec2(-200, -20), width = 400, height = 20 })
floor:add_body({ type = "static" })
-- New bodies are found once the simulation has stepped.
datumhue.time.sleep(0.1)
-- Walk 50 right and fall 30: the floor takes the fall.
local move = controller:move(vec2(50, -30), 1 / 60)
print(move.translation.x, move.grounded) --> 50.0 true
-- move only measures; moving the body is up to you.
hero.pos = hero.pos + move.translation

returns physics.CharacterMove record 4 keys

KeyTypeDescription
translationVec3The movement to apply this frame, in the frame of the body's pos (relative to its parent for a nested body) — the body is not moved; set body.pos = body.pos + translation.
groundedbooleanStanding on ground after applying translation. False while the move commanded upward motion (a jump in progress), so a launching jump is never reported grounded.
sliding_down_slopebooleanThe character was let slide down a too-steep slope this frame.
collisionsphysics.CharacterCollision[]Surfaces hit during the slide, in application order; empty if unobstructed. Sensors are not surfaces: the character passes through them, and they report it through their collision handlers.

CharacterController:push_dynamics

method
CharacterController:push_dynamics(mass: number)

Push the dynamic bodies the character pressed against during the most recent move, using mass (kg) as the character's effective mass for the reduced-mass impulse. Call it after move in the same frame; raises if no move has run since the last push.

CharacterController:remove

method
CharacterController:remove()

Detach the controller from its body (the body and its collider remain). Idempotent.

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page