Navmesh Link
Updated
A shortcut between two points: a jump, ladder or teleport.
- Type
ent-navmesh-link- Script class
NavMeshLinkEntity- Family
- Navigation
Overview
Section titled “Overview”A NavMesh Link is a shortcut on the navmesh: it joins two points that the walkable surface does not otherwise connect, such as a gap to jump, a ledge to drop from or a ladder. The link entity’s own position is the start, and its end prop is the far end, as an offset from it. Rotating the entity turns the whole link. In the editor it shows as an arc with arrowheads, a jump icon and a ring at each end; you drag the far end with the move gizmo.
Links are baked into the NavMesh Surface, like the rest of the navmesh. A character following a path that uses a link walks to its entry, jumps across along the arc, and carries on to its destination. While it crosses, its NavMesh Agent’s isGrounded is false, and a Character Controller on it reports the jump state.
Use a link whenever characters must cross a place where there is no continuous floor. Characters on a navmesh have no gravity and cannot jump on their own: without a link, a gap is simply a wall.
The props that matter most:
endis the far end, as an{ x, y, z }offset in the link entity’s local space.bidirectional:truelets characters cross both ways;falseonly from the start to the end, which suits a drop they cannot climb back up.arcHeightis the peak height of the jump, in metres.0is a flat crossing.radiusis the capture radius at each end, in metres: how close a character must come to an end to be taken onto the link. It is not the width of the link.
Set it up
Section titled “Set it up”- Make sure the scene has a NavMesh Surface and that both sides have walkable, baked ground.
- Add a NavMesh Link entity and place it on the ground at the start of the crossing. See Scenes and hierarchy.
- Drag its far end, or set
end, so it rests on the ground on the other side. - Set
bidirectionalandarcHeightfor the kind of crossing: a two-way jump, or a one-way drop. - Select the NavMesh Surface and bake again. A link takes effect only once it is baked in.
Examples
Section titled “Examples”Open and close a shortcut
Section titled “Open and close a shortcut”Remove a jump from the navmesh when a bridge is raised, and put it back when it is lowered.
#pragma lifecycle(startup)
function startup() { const link = findEntity('Bridge Link'); const surface = findEntity('NavMesh Surface').getComponent(NavMeshSurfaceComponent);
async function setOpen(open) { link.setEnabled(open); const ok = await surface.bake(); log(open ? 'Bridge lowered' : 'Bridge raised', ok ? '' : '(bake failed)'); emit('bridge/changed', { open }); }
on('bridge/raise', () => setOpen(false)); on('bridge/lower', () => setOpen(true));}How it works:
setEnabled(false)switches the link entity off; switching it changes what the surface bakes, so the old navmesh no longer matches.bake()rebuilds the navmesh from the current geometry and the links that are on. It returns a promise oftrueon success, which theasyncfunction awaits.- Characters plan their next paths on the new navmesh, so they take the long way round while the bridge is up.
Play a jump animation on the crossing
Section titled “Play a jump animation on the crossing”Notice when a character starts and ends a link crossing, and tell its animation script.
#pragma lifecycle(startup, update)
let agent;let wasGrounded = true;
function startup() { // This Behavior sits under a character with a NavMesh Agent. agent = self.parent.getComponent(NavMeshAgentComponent);}
function update() { if (!agent) return; const grounded = agent.isGrounded; if (grounded === wasGrounded) return; wasGrounded = grounded; emit(grounded ? 'hero/land' : 'hero/jump');}How it works:
- A NavMesh Agent’s
isGroundedisfalseonly while it crosses a link, so its change marks the start and the end of the jump. - The script remembers the last value and emits only when it changes, not every frame.
- With a Character Controller on the character, you can instead listen to its
EventType.CharacterController.StateChangeevent, whosedata.stateisjumpwhile it crosses.
Make a drop one way only
Section titled “Make a drop one way only”Turn a two-way jump into a one-way drop at runtime, for example after a ladder breaks.
#pragma lifecycle(startup)
function startup() { const link = findEntity('Ladder Link').getComponent(NavMeshLinkComponent); const surface = findEntity('NavMesh Surface').getComponent(NavMeshSurfaceComponent);
on('ladder/broken', async () => { link.setProps({ bidirectional: false, arcHeight: 0 }); if (await surface.bake()) log('The ladder only goes down now'); });}How it works:
getComponent(NavMeshLinkComponent)reaches the link’s settings.bidirectional: falseallows crossing from the start to the end only;arcHeight: 0makes the crossing a straight drop instead of a jump.- Any change to a link needs a new bake before characters use it.
- Put both ends on baked ground. An end that floats in the air or sits inside an obstacle is never reached, however large its
radius. - Moving or editing a link clears the surface’s baked data. Bake again in the editor before you publish.
- Use
bidirectional: falsefor drops: characters can then go down but never try to jump back up.
Components
Section titled “Components”What a new Navmesh Link is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.
| Component | Type | Role | Per entity | What it does |
|---|---|---|---|---|
| Layer | comp-layer |
Required | One | Puts the entity on a render/raycast layer so cameras and rays can include or skip it. |
| Lock | comp-lock |
Required | One | Editor-only flag that stops the entity from being selected or moved. |
| Enable | comp-enable |
Required | One | Turns the entity and its children on or off: hides them and stops their behavior. |
| Transform | comp- |
Required | One | Position, rotation and scale of the entity, with optional editor-only per-axis locks. |
| Navmesh Link | comp- |
Required | One | A shortcut between two points: a jump, ladder or teleport. |
You can also add 1 optional components, such as Signal Emitter.
The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).
| Prop | Default | Range |
|---|---|---|
end |
{"x":0,"y":0,"z":2} |
|
radius |
0.5 |
0. |
bidirectional |
true |
|
arcHeight |
1.2 |
0 ≤ x ≤ 10 |
Events
Section titled “Events”With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.
It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
A hero walks back and forth between two platforms that do not touch: a NavMesh Link across the gap lets its path continue, and the script logs when the agent leaves the ground to cross it.
Watch the hero jump the gap on each crossing. Drag to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My Navmesh Link.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My Navmesh Link'); if (!(entity instanceof NavMeshLinkEntity)) return;
// Its Navmesh Link component holds the settings listed under Props. const component = entity.getComponent(NavMeshLinkComponent); log('radius is', component.props.radius); component.setProps({ radius: 0.75 });}