Skip to content

Travel Point

Updated

Walking into an in portal sends the player to an out portal of the same channel.

Type
ent-travel-point
Script class
TravelPointEntity

A Travel Point is a portal. Walking into an in portal sends the player to an out portal on the same channel, where they land facing the out portal’s forward. In play, each portal shows an upright ring: cyan for in, amber for out. In the editor it shows the ring and a ground marker, and sends no one.

A player who is already inside an in portal, or who lands inside one, must step out before it sends them again, so an out portal standing inside an in portal never loops. Scripts can also send the player through an in portal at once with travel(), exactly as walking in would. Each player moves only themselves: nothing is sent over the network.

Choose a Travel Point when moving somewhere should feel like walking through a door. For a destination the player clicks, use a Spot Point; for where players appear when they join, use a Spawn Point.

The props that matter most:

  • port: in sends whoever walks into it on; out is where they arrive.
  • channel pairs portals. An in portal sends the player to an out portal with the same channel name. Several out portals on one channel take arrivals in turn, skipping any that are off.
  • radius: on an in portal, the trigger, a cylinder that reaches from half a unit below the point to two and a half above; on an out portal, the arrival pad. It scales with the entity.
  • appearance: portal shows the ring in play; invisible shows nothing, so you can dress the portal with your own model while it still works.
  • color recolours the ring. Empty uses the port’s own colour.
  1. Add a Travel Point entity where the player should leave, and keep its port on in. See Scenes and hierarchy.
  2. Add a second Travel Point where the player should arrive, set its port to out, and rotate it so its forward points the way the player should face.
  3. Give both the same channel, such as vault. Use a different channel for every other pair of portals.
  4. Adjust radius so the in portal’s trigger covers the doorway, and pick an appearance and color.
  5. To react from a script, add a Signal Emitter to either portal: the in portal sends TravelPoint::enter, the out portal TravelPoint::arrive.

Show a message and change the music when the player comes out of a portal.

ArrivalNotice.jx
#pragma lifecycle(startup)
function startup() {
// The out portal has a Signal Emitter with the signal 'portal/garden'.
on('portal/garden', (event) => {
if (event.eventType !== EventType.TravelPoint.Arrive) return;
emit('hud/toast', { text: 'You reached the Secret Garden' });
emit('music/garden');
});
}

How it works:

  • The out portal sends TravelPoint::arrive through its Signal Emitter when the player lands on it.
  • The event carries no data; event.entityId tells which portal sent it when several share a signal.
  • The script republishes plain signals, hud/toast and music/garden, that the HUD and music scripts listen to.

Keep a portal closed until the player collects a key, then light it up.

VaultPortal.jx
#pragma lifecycle(startup)
function startup() {
const gate = findEntity('Vault Portal In')?.getComponent(TravelPointComponent);
if (!gate) return;
gate.setEnabled(false); // closed: no ring, no trigger
on('key/collected', () => {
gate.setEnabled(true);
gate.setProps({ color: '#facc15' });
log('The vault portal is open');
});
}

How it works:

  • A disabled Travel Point component neither shows nor sends anyone, and its travel() returns false.
  • When another script emits key/collected, setEnabled(true) opens the portal and setProps recolours its ring gold.

Let a lever choose where a single in portal leads, by changing its channel.

DestinationLever.jx
#pragma lifecycle(startup)
const CHANNELS = ['harbour', 'castle', 'forest'];
let choice = 0;
function startup() {
// Out portals with these channels stand in each area.
const door = findEntity('Hub Portal')?.getComponent(TravelPointComponent);
if (!door) return;
door.setProps({ channel: CHANNELS[choice] });
// The lever has a Selectable and a Signal Emitter with the signal 'lever'.
on('lever', (event) => {
if (event.eventType !== EventType.Selectable.Select) return;
findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again
choice = (choice + 1) % CHANNELS.length;
door.setProps({ channel: CHANNELS[choice] });
emit('hud/toast', { text: `The portal now leads to the ${CHANNELS[choice]}` });
});
}

How it works:

  • Each area has an out portal with its own channel: harbour, castle, forest.
  • Clicking the lever moves to the next channel; setProps({ channel }) makes the hub’s in portal lead there from the next crossing.
  • A channel is any non-empty name, so it can be built from game state.

Send the player through a portal from a UI menu, without walking to it.

FastTravel.jx
#pragma lifecycle(startup)
const PORTALS = { harbour: 'Portal To Harbour', castle: 'Portal To Castle' };
function startup() {
// Menu buttons emit 'travel/go' with { place: 'harbour' } or { place: 'castle' }.
on('travel/go', (data) => {
const portal = findEntity(PORTALS[data.place] ?? '')?.getComponent(TravelPointComponent);
if (!portal || !portal.travel()) log('Cannot travel to', data.place);
});
}

How it works:

  • travel() on an in portal does exactly what walking into it does, so the same portals serve walkers and the menu.
  • It returns false from an out portal, in the editor, while the portal is off, or when no out portal shares its channel.
  • data is the object passed to emit, because this signal comes from a script and not from a Signal Emitter.
  • A portal that never fires usually has no out portal on the same channel, or the player started inside it. Players must walk in from outside.
  • Place the out portal’s pad on open ground, clear of the in portal’s trigger, so arrivals have room to step away.
  • Portals run only in play. To test one, enter play and walk through it.

What a new Travel 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.
Travel Point comp-travel-point Required One Walking into an in portal sends the player to an out portal of the same channel.

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
port "in"
channel "main"
radius 0.6 0.001 ≤ x ≤ 100
color ""
appearance "portal"

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

  • TravelPoint::enter
  • TravelPoint::arrive

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

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