Events
Events make your scene react to people without any code. When something happens, the object does the things you listed.
WHEN someone taps the door
THEN swing it open over 600 ms
disable the "locked" sign
send the signal "door-open"
The when is a trigger. The then is a list of steps. An object can have as many events as you like, and each one runs on its own.
Add an event
- Select the object.
- In the inspector, click + new component and choose Events. The component starts with one event, set to Press on the object.
- Click the event. The Event settings panel opens. To add another event, click + add event.
- Pick a trigger, or keep Press on the object.
- Click + add action and pick a step. The list has a search box, and the steps are grouped under Actions, Animations, States and Logic.
- Add more steps the same way. They run in order.
The trigger reference lists every trigger.
The step reference lists every step. Both are
always up to date. They show each name in the editor next to its code name for scripts:
Send signal is emit_signal, and Signal is on-signal.
Triggers
A trigger is the moment an event starts. The references above list each trigger's settings. The tables below say what each one is for.
Pointer and keys
| In the editor | Fires when |
|---|---|
| Press on the object | someone taps or clicks it; branches for click, press and release |
| Hover | the cursor moves onto the object or leaves it |
| Double click | two clicks on the same object within 300 ms |
| Long press | the object is held for 450 ms without moving |
| Key | a key is pressed or released |
| Scroll | the wheel turns; you can pick a direction |
| Drag | someone drags the AR content they placed |
| Pinch | someone pinches placed AR content to scale it |
| Rotate | someone twists placed AR content |
Drag, Pinch and Rotate work only on surface scenes, because they act on content the visitor placed. They fire again and again while the finger moves, not just once.
Lifecycle
| In the editor | Fires when |
|---|---|
| Launch | the scene starts; every object gets it |
| Resize | the window or screen changes size |
| Pause | the app or tab goes to the background |
| Resume | the app or tab comes back |
| Visibility | the object is shown or hidden |
Sounds keep playing when a visitor switches apps, unless you stop them. Stop them on Pause, for example by switching to a state in which the sound is muted, and start them again on Resume.
AR tracking
| In the editor | Fires when |
|---|---|
| Detect | the marker or surface is found |
| Tracking lost | tracking is lost |
| Placed | the visitor placed the content |
| VPS ready | positioning has started |
| VPS localized | the visitor's real position was found |
| VPS localization failed | the position was not found yet |
| VPS error | positioning could not run at all |
The editor offers only the triggers your scene's anchor can produce. Detect fires once, when tracking starts, not on every frame.
VPS localization failed fires often while the visitor walks around looking for a spot the map knows. Treat it as "keep trying", not as an error to show.
Time and distance
| In the editor | Fires when |
|---|---|
| Delay | once, after a delay |
| Every N seconds | again and again; a repeat count of 0 means forever |
| Distance | something comes within a distance, or moves away |
| Variable change | a variable gets a new value |
Distance has an At start option. Turn it on if an object may already be close when the scene opens. Without it, the event waits until something moves.
States, collisions and signals
| In the editor | Fires when |
|---|---|
| State active | this object enters the state you picked |
| State inactive | this object leaves that state |
| Collision | this object touches another; use Collide with to limit which ones |
| UI action | someone pressed a button on an interface card |
| Signal | another event sent a signal |
| Game controls | the character starts standing, moving, running or jumping |
Branches
Some triggers have branches, so one event can handle every outcome. For example, one Distance event can answer both "came closer" and "moved away".
| Trigger | Branches |
|---|---|
| Distance | On coming closer, On moving away |
| Key | On press, On release |
| Hover | On enter, On leave |
| Press on the object | On click or tap, On press, On release |
| Visibility | On show, On hide |
| Game controls | On idle, On move, On run, On jump |
Each branch gets its own list of steps. A trigger without branches has one list, On activation.
Choose which objects a step affects
Every step has a Target object field.
- Leave it empty and the step acts on the object that owns the event. This is the usual case.
- Pick objects and the step acts on them instead. This is how one button opens three doors.
Taps reach parent objects
A tap, a hover or a card action reaches the object and all its parents.
So you can put one event on a group, and it catches taps on anything inside it. You do not need to copy the same event onto forty objects.
This also means:
- "tap anywhere on this panel" is one event on the panel;
- moving the cursor between two children of the same parent does not fire hover or leave on the parent, because the cursor never left it.
Some triggers work differently:
- Collision fires only on the objects that touched.
- Key, Scroll, Resize and Launch are not about one object, so every object gets them.
Events, patches and scripts hear the same taps, keys and collisions. A few triggers arrive in scripts under other names. See The ctx API.
If the same object reacts to the same trigger in an event and in a script, it runs twice. When something fires twice, this is almost always the reason.
Use several keys for one event
"Jump on Space or W" is one event, not two. Click the Key field and press the first key. Then click or and press the next one. Add as many as you need.
- Each key in the list stands on its own. A modifier such as Ctrl belongs only to the key it was pressed with.
- The trigger's other settings, such as Auto-repeat, apply to every key in the list.
- A mouse button works in the same field. The list then holds mouse buttons only.
The event keeps these keys as text. An assistant or a script writes them like this:
ArrowUp ctrl+KeyW KeyA+KeyS Space+double mouse:middle
You can also use a key binding instead of a key. Set up bindings in Project settings → Key bindings. Change the key for "jump" there once, and every event that uses "jump" follows. This helps when someone asks for left-handed controls.
Steps
The step reference lists each step's settings.
Links, calls and scene changes
| In the editor | Does |
|---|---|
| Scene transition | goes to another scene |
| Space transition | goes to another space, and to a specific scene if you pick one |
| Open URL | opens a link, in this tab or a new one |
| Open messenger | opens Facebook, VK, OK, Instagram, Telegram, WhatsApp or Viber |
| Call phone number | starts a phone call |
| Compose email | starts an email |
| File download | downloads a file from your project |
| Contact download | offers a contact card made from the fields you fill in |
Open messenger needs different details for each app:
- a page ID for Facebook, VK and OK;
- a username for Instagram and Telegram;
- a phone number for WhatsApp and Viber.
Show, hide and change objects
| In the editor | Does |
|---|---|
| Show / hide object | shows or hides the targets; on a scene, it makes that scene active |
| Set state | switches to a state you saved, smoothly if you set a duration |
| Override properties | applies a few values once, like a temporary state |
Animation
| In the editor | Does |
|---|---|
| Play animation | plays an animation from the timeline, with loop mode, repeats, speed and delay |
| Stop animation | stops one |
Play animation can start an animation that belongs to any object. So one button can start a sequence that moves several things at once.
To move, fade or recolour something, make an animation in the Animation panel, then play it with this step. For a single change, Set state with a duration is enough.
Projects made earlier can also have the Transformation, Opacity, Material, Bone transform and Built-in animation steps. They still run in those projects, but the editor no longer offers them. Material, for example, blends the targets' colour, opacity, glow and surface settings toward a saved material, and keeps each slot's type and textures.
Movement
| In the editor | Does |
|---|---|
| Follow object | keeps following another object; you set distance, offset, smoothing and speed |
| Look at object | turns to face something without moving |
| Stop following | stops following and looking |
| Fly along path | travels along a path |
| Stop path flight | stops the path flight |
Logic
| In the editor | Does |
|---|---|
| If — otherwise | checks a condition, then runs one of two lists of steps |
| Set variable | sets a variable, adds to it, or toggles it |
| Send signal | sends a signal to the selected objects or the whole scene |
| Wait, then | waits, then runs the steps inside it |
Pointer
Lock pointer hides the mouse cursor and lets the scene use its movement. First-person games need this, so the cursor does not leave the window. Release pointer gives the cursor back.
Triggers and steps from plugins
A plugin added to your project can bring its own triggers and steps. They appear in the lists under the plugin's name, and you use them like the built-in ones.
- They are there only in projects the plugin is added to.
- A plugin's trigger can have settings. The event then runs only when they match. Leave a setting empty to react every time.
- If the plugin is removed from the project, its triggers never fire and its steps are skipped.
To make your own, see Runtime code.
Add a condition
A condition is a step: If — otherwise. You can put one inside another to get more than two outcomes.
Choose what the step checks in the Condition field:
| In the editor | Checks | Fields you fill in |
|---|---|---|
| Always | nothing; it is always true | — |
| Variable | a variable's value | Variable, Compare, Value |
| Distance | how far this event's object is from another object | Object, Compare, Threshold |
| State | which state another object is in | Object, State |
| Visibility | whether something is visible | Object, Expected |
| Chance | a random chance | Threshold, as a percentage |
How values are compared:
3is read as a number,trueas yes/no, and anything else as text.==and!=check for an exact match.>,>=,<and<=compare numbers.
Variables, signals and timers
Variables last for one visit. They start empty each time someone opens your project. To give them starting values, set them in an event with the Launch trigger. A script sees the same variables as globals.
Signals let one event start others without copying steps. For example, several events can
listen for level-complete, and any event can send it. If a signal keeps sending itself, it
stops after eight rounds, so the scene does not freeze.
Timers (Delay and Every N seconds) start when their object turns on and reset when it turns off. When the object turns on again, the count starts over. Missed ticks are not fired all at once.
States
A state is a saved look of an object: its position, colour, visibility and more. The Set state step switches to it. With a duration, the change is smooth.
Use states for a switch, a highlight, or a door that is open or closed.
If one of the object's states is selected, changing the object changes that state. This is what you want when you build states. It is confusing if you forgot a state was selected.
More in States.
Re-tracking
In AR scenes, each event has a re-tracking mode. It sets what happens when the marker is lost and found again:
- start the steps over right away;
- never start them again;
- start them again once the current steps have finished.
Next: Animation — make things move.