This script allows a player to climb up and down ladders. The Ladder object must be placed in the scene as a vertical trigger (non-solid), so the player can freely enter and exit the climbable area.
trigger = true and static = true,
with no gravity. It only acts as a detection zone — not a solid collider.
// ================================================
// 🪜 ladder.js — Ladder climbing behavior
// ================================================
// Ladders must be TRIGGER objects (not solid)
function Start(obj) {}
function Update(obj, dt) {}
function OnTriggerEnter(obj, other) {
if (other.type !== "player") return;
// Enable ladder mode when entering
other.isOnLadder = true;
other.isClimbing = true;
// Cancel velocity to prevent snapping or jitter
other.vx = 0;
other.vy = 0;
// Cancel jump state if active
other.jumping = false;
}
function OnTriggerExit(obj, other) {
if (other.type !== "player") return;
// Leaving the ladder
other.isOnLadder = false;
// If climbing, disable climb state
if (other.isClimbing) {
other.isClimbing = false;
other.vy = 0;
}
}
vx = 0 and vy = 0 to avoid movement glitches.collision: truetrigger: true (very important)static: truegravity: 0script: "ladder.js"components: [ { type: "Script", scriptFile: "ladder.js" } ]
The player script checks isOnLadder = true and allows: