ledge.module
README.md
ledge (climbKit)
The physics probes behind ClimbMover, usable on their own by any mover: a custom controller, an NPC planner deciding whether a ledge is reachable, a level-validation tool checking a roofline is climbable. Pure functions over the physics world's colliders; they answer in edit mode too.
local Ledge = require("@root::climbKit.ledge") -- ~.ledge from inside the package
local spot, why = Ledge.findLedge({
feet = body.position, dirX = 0, dirZ = -1,
height = 1.8, radius = 0.3, reach = 2.3, selfId = body.id,
})
if spot then print("mantle", spot.height, "onto a", spot.slope, "degree top at", spot.landing) else print(why) end
| Function | Answers |
|---|---|
findLedge(opts) | A top in front within reach the body can stand on: top, landing (feet position), risen (where the straight rise ends), height, slope, edgeDistance, climbable; or nil and why (no top, too tall, too low, too high, no headroom on top, blocked above, blocked across, blocked over the edge). |
wallAhead(feet, dx, dz, height, distance, selfId?) | Nearest steep surface in front at 35/55/85% of the height, with climbable. |
wallRay(feet, dx, dz, atHeight, distance, selfId?, maxNormalY?) | One horizontal wall ray. |
isClimbable(entityId, hit?) | The climbable attribute on the entity or nearest ancestor that has one decides (true or false); otherwise the registered climb rules decide. |
addClimbRule(name, rule) / removeClimbRule(name) / hasClimbRule(name) | Rules that make unmarked surfaces climbable by what they are: rule(entityId, hit) -> true / false / nil. |
fits(feet, height, radius, lift?, selfId?) | Whether a standing capsule fits there. |
pathClear(feet, delta, height, radius, selfId?) | Whether a capsule sweep along delta is clear. |
mantlePoint(start, risen, landing, t, split?) | The feet along a mantle at progress t: up first, then over. |
mantleDuration(height, reach, minTime, maxTime) | Mantle time scaled by height. |
groundBelow(p, above, depth, selfId?) | Ground ray under a point. |
Positions are feet (capsule bottom) in world space; directions are horizontal unit vectors; up is world +Y.