Skip to content

Components

Updated

An entity on its own is just a place in the scene. Components give it everything else: how it looks, what it does, and how it reacts. You build objects by combining components, the way you would assemble parts.

You want an entity to… Add the component
have a shape a Geometry
have a colour and a surface a material, such as Standard Material
give off light from a point, like a bulb Point Light
fall, bounce and collide a Rigid Body and a collider
react to clicks, taps and touches Selectable
be picked up and moved Grabbable
play a sound Audio
send its events on a named signal Signal Emitter
run code Behavior

Each component has settings called props: a light’s colour and intensity, a rigid body’s mass, a sound’s volume. You edit them in XR Creator’s Properties panel, and scripts can read and change them.

Some components are required by the entity type and are always there. A new entity also starts with a few default components, which you may remove. Others are added only when you need them, with Add Component.

Every component can be switched off without removing it: it stays on the entity with its props, and does nothing until you switch it on again.

Component What it decides
Transform Where the entity is: its position, rotation and scale.
Enable Whether the entity is on. Switched off, it and everything inside it disappear and stop.
Layer Which layer the entity is on.
Lock Whether XR Creator can select and move it.

Many components report what happens to them as events: a Selectable when it is clicked, a Rigid Body when it collides, a video when it ends. A Signal Emitter on the entity announces those events under a name, a signal, so scripts and other entities can respond. No code is needed to connect simple reactions: an Enable on Signal component switches its entity, or some of its components, on or off when a signal arrives.

Recolor.jx
#pragma lifecycle(startup)
function startup() {
const lamp = findEntity('Lamp');
// Read and change a component's props.
const light = lamp.getComponent(PointLightComponent);
light.setProps({ color: '#ffd8a8', intensity: 2 });
}