Skip to content

Spot Point

Updated

Marks a spot in the world that gameplay systems can find and send the player to.

Type
ent-spot-point
Script class
SpotPointEntity

A Spot Point is a click-to-go destination. In play, it shows a marker (a pin, a star, an orb…), and clicking that marker, or any mesh placed under the spot point, moves the player onto it at once. Scripts can send the player there too, with travel(). It suits galleries, showrooms, guided tours and touch screens, where walking is slow or awkward. In the editor it shows the marker and an arrow for the arrival facing, and clicking it does nothing.

Like the other navigation points, it moves the main camera, or the character that camera follows; in an immersive session it moves the player rig. Each player moves only themselves: nothing is sent over the network.

Pick a sibling for other jobs: a Spawn Point places players when they join, and a Travel Point is a portal that sends whoever walks into it somewhere else.

The props that matter most:

  • appearance is the marker: pin, star, diamond, orb, chevron, heart, info, or invisible. With invisible, nothing is drawn in play; put your own model under the spot point and clicking it travels there.
  • color is the marker’s colour.
  • facing: align turns the player to the spot point’s own facing (its forward, -Z); keep leaves them facing the way they already were.
  • ocupable reserves the point for whoever arrives. Nobody else can travel there until they walk farther than radius away, and the marker hides while it is taken.
  • radius is the area, in metres, held for whoever stands on the point. It scales with the entity.

A new Spot Point also carries a Billboard with lockY, which turns only its marker toward the camera, never the arrival facing.

  1. Add a Spot Point entity to the scene where the player should stand. See Scenes and hierarchy.
  2. Rotate it so its arrow points at what the player should see on arrival, and keep facing on align.
  3. Choose an appearance and a color for the marker, or set appearance to invisible and place your own model under it.
  4. Leave ocupable on for seats and viewing spots that hold one person; turn it off for places anyone can use at any time.
  5. To react from a script, add a Signal Emitter to the spot point and give it a signal name.

Send the player to a named spot point when a UI button is pressed.

GoToStage.jx
#pragma lifecycle(startup)
function startup() {
// The 'Stage' button has a Signal Emitter with the signal 'menu/stage'.
const stage = findEntity('Stage Spot')?.getComponent(SpotPointComponent);
on('menu/stage', (event) => {
if (event.eventType !== EventType.UIButton.Press) return;
if (!stage || !stage.travel()) log('The stage spot is taken or unavailable');
});
}

How it works:

  • getComponent(SpotPointComponent) reaches the Spot Point component, which owns travel().
  • travel() moves the player at once and returns true. It returns false in the editor, while the point is off, without a camera, or while someone else holds it.
  • The button’s events arrive as { entityId, eventType, data }; the check keeps only EventType.UIButton.Press.

Move the player through a list of stops, pausing at each one, and announce every arrival.

AutoTour.jx
#pragma lifecycle(startup)
const STOPS = ['Stop Entrance', 'Stop Sculpture', 'Stop Window', 'Stop Exit'];
const PAUSE = 8000; // milliseconds at each stop
let index = 0;
let cancelNext = null;
function visit() {
const point = findEntity(STOPS[index])?.getComponent(SpotPointComponent);
if (point && point.travel()) emit('tour/stop', { name: STOPS[index], number: index + 1 });
index += 1;
cancelNext = index < STOPS.length ? delay(visit, PAUSE) : null;
}
function startup() {
on('tour/start', () => {
if (cancelNext) cancelNext();
index = 0;
visit();
});
on('tour/stop-tour', () => {
if (cancelNext) cancelNext();
cancelNext = null;
});
}

How it works:

  • visit() travels to the current stop, announces it on tour/stop, then schedules the next stop with delay, which returns a function that cancels it.
  • A stop that cannot be reached (taken, or switched off) is skipped instead of stopping the tour.
  • Any button or script starts the tour with emit('tour/start') and stops it with emit('tour/stop-tour'). A narration script can listen to tour/stop to play the right commentary.

Keep a special viewpoint hidden until the player earns it, then show it with a gold star.

SecretViewpoint.jx
#pragma lifecycle(startup)
function startup() {
const viewpoint = findEntity('Rooftop Spot');
if (!viewpoint) return;
viewpoint.setEnabled(false); // no marker, no clicks, travel() returns false
on('quest/complete', () => {
viewpoint.setEnabled(true);
viewpoint.getComponent(SpotPointComponent).setProps({ appearance: 'star', color: '#facc15' });
log('The rooftop viewpoint is open');
});
// The viewpoint has a Signal Emitter with the signal 'rooftop'.
on('rooftop', (event) => {
if (event.eventType === EventType.SpotPoint.Occupied) emit('music/rooftop');
if (event.eventType === EventType.SpotPoint.Release) emit('music/default');
});
}

How it works:

  • setEnabled(false) switches the whole entity off: its marker disappears and it cannot be travelled to.
  • When another script emits quest/complete, the entity is switched on and setProps changes the marker to a gold star.
  • SpotPoint::occupied is sent when the player arrives and SpotPoint::release when they leave or the reservation is released; the script switches the music with them.
  • A marker is about a metre tall and solid: a wall or a model in front of it hides it and catches the click. Keep the line of sight clear.
  • An invisible spot point with nothing under it can only be reached from a script with travel().
  • Reservation is local to each player’s device and is never saved. Do not rely on ocupable to keep two players apart.

What a new Spot Point 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-transform Required One Position, rotation and scale of the entity, with optional editor-only per-axis locks.
Spot Point comp-spot-point Required One Marks a spot in the world that gameplay systems can find and send the player to.
Billboard comp-billboard Starts with One Keeps the entity turned toward the camera, for sprites and labels.

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
ocupable true
facing "align"
radius 0.5 0.001 ≤ x ≤ 100
color "#38bdf8"
appearance "pin"
Prop Default Range
lockY true

With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.

  • SpotPoint::occupied
  • SpotPoint::release

Like every entity, it also reports: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.

Run it in the browser, read its scripts, and download it as an XR Creator project.

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 Spot Point.

SpotPointEntity.jx
#pragma lifecycle(startup)
function startup() {
// Find the entity by the name it has in the Hierarchy.
const entity = findEntity('My Spot Point');
if (!(entity instanceof SpotPointEntity)) return;
// Its Spot Point component holds the settings listed under Props.
const component = entity.getComponent(SpotPointComponent);
log('radius is', component.props.radius);
component.setProps({ radius: 0.75 });
}