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.
Examples
Section titled “Examples”| 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 |
Props: a component’s settings
Section titled “Props: a component’s settings”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.
Components almost every entity has
Section titled “Components almost every entity has”| 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. |
Events
Section titled “Events”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.
Components in a script
Section titled “Components in a script”#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 });}Learn more
Section titled “Learn more”- Components in the Scripting API: props, enabling, the common components and layers
- Component reference: every component, its props and events
- Properties and components in XR Creator