Skip to content

NavMesh Links

Updated

A navmesh only joins ground that touches. To let characters jump a gap, drop off a ledge or climb a ladder, add a NavMesh Link between the two places. Agents then plan paths through it like any other ground.

A NavMesh Link (comp-navmesh-link) joins two points the walkable surface does not otherwise connect. The link entity’s position is the start, and end is the far end relative to it. Links are baked into the surface, so moving one requires a new bake.

Prop Type Default Description
end { x, y, z } { x: 0, y: 0, z: 2 } The far end, as an offset in the link entity’s local space.
radius number 0.5 The capture radius at each end, in metres.
bidirectional boolean true Traversable both ways. false goes from start to end only.
arcHeight number 1.2 Peak jump height, in metres. 0 is flat.

An agent following a path to a link walks to its entry, jumps across, and carries on. While crossing, its isGrounded is false, and a Character Controller’s state is jump. Put both ends on baked ground.

Two platforms that do not touch, and a NavMesh Link from the edge of one to the edge of the other. The hero walks back and forth between them; its path goes through the link, and the script logs when it leaves the ground.

JumpTheGap.jx
#pragma lifecycle(startup, update)
const SPOTS = [{ x: -3, y: 0, z: 0 }, { x: 3, y: 0, z: 0 }];
let character;
let agent;
let target = 1;
let walking = false;
let resting = false;
let inAir = false;
function startup() {
const hero = findEntity('Hero');
character = hero.getComponent(CharacterControllerComponent);
agent = hero.getComponent(NavMeshAgentComponent);
on('hero', (event) => {
if (event.eventType !== EventType.CharacterController.Arrive) return;
log('Arrived on the', target === 1 ? 'right' : 'left', 'platform');
target = 1 - target;
walking = false;
resting = true;
delay(() => { resting = false; }, 1000);
});
}
function update() {
// moveTo is false until the agent has joined the navmesh, a few frames into play.
if (!walking && !resting) walking = character.moveTo(SPOTS[target]);
if (agent.isGrounded === inAir) {
inAir = !agent.isGrounded;
log(inAir ? 'Jumping the gap' : 'Landed');
}
}
  • Without the link, moveTo to the other platform would find no route. With it, the path runs to the link’s start, across, and on.
  • The link starts 0.4 m inside the left platform and ends 0.4 m inside the right one, so both ends sit on baked ground.
  • isGrounded is false only while the agent crosses a link, so watching it is enough to time a jump sound or animation.
  • CharacterController::arrive comes through the hero’s Signal Emitter. The script waits a second, then walks back.
  • Jumping on a navmesh. There is no gravity or jump on a navmesh; add a NavMesh Link for gaps and drops.
  • Moving a link in play. Links are baked into the navmesh: after moving one, bake again (see Navigation meshes).