Skip to main content

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​

  1. Select the object.
  2. In the inspector, click + new component and choose Events. The component starts with one event, set to Press on the object.
  3. Click the event. The Event settings panel opens. To add another event, click + add event.
  4. Pick a trigger, or keep Press on the object.
  5. Click + add action and pick a step. The list has a search box, and the steps are grouped under Actions, Animations, States and Logic.
  6. Add more steps the same way. They run in order.
Two lists to keep open

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 editorFires when
Press on the objectsomeone taps or clicks it; branches for click, press and release
Hoverthe cursor moves onto the object or leaves it
Double clicktwo clicks on the same object within 300 ms
Long pressthe object is held for 450 ms without moving
Keya key is pressed or released
Scrollthe wheel turns; you can pick a direction
Dragsomeone drags the AR content they placed
Pinchsomeone pinches placed AR content to scale it
Rotatesomeone 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 editorFires when
Launchthe scene starts; every object gets it
Resizethe window or screen changes size
Pausethe app or tab goes to the background
Resumethe app or tab comes back
Visibilitythe object is shown or hidden
Stop sound on Pause

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 editorFires when
Detectthe marker or surface is found
Tracking losttracking is lost
Placedthe visitor placed the content
VPS readypositioning has started
VPS localizedthe visitor's real position was found
VPS localization failedthe position was not found yet
VPS errorpositioning 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.

A failed VPS localization is normal

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 editorFires when
Delayonce, after a delay
Every N secondsagain and again; a repeat count of 0 means forever
Distancesomething comes within a distance, or moves away
Variable changea 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 editorFires when
State activethis object enters the state you picked
State inactivethis object leaves that state
Collisionthis object touches another; use Collide with to limit which ones
UI actionsomeone pressed a button on an interface card
Signalanother event sent a signal
Game controlsthe 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".

TriggerBranches
DistanceOn coming closer, On moving away
KeyOn press, On release
HoverOn enter, On leave
Press on the objectOn click or tap, On press, On release
VisibilityOn show, On hide
Game controlsOn 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.

Handle each trigger in one place

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.

In the editorDoes
Scene transitiongoes to another scene
Space transitiongoes to another space, and to a specific scene if you pick one
Open URLopens a link, in this tab or a new one
Open messengeropens Facebook, VK, OK, Instagram, Telegram, WhatsApp or Viber
Call phone numberstarts a phone call
Compose emailstarts an email
File downloaddownloads a file from your project
Contact downloadoffers 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 editorDoes
Show / hide objectshows or hides the targets; on a scene, it makes that scene active
Set stateswitches to a state you saved, smoothly if you set a duration
Override propertiesapplies a few values once, like a temporary state

Animation​

In the editorDoes
Play animationplays an animation from the timeline, with loop mode, repeats, speed and delay
Stop animationstops 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 editorDoes
Follow objectkeeps following another object; you set distance, offset, smoothing and speed
Look at objectturns to face something without moving
Stop followingstops following and looking
Fly along pathtravels along a path
Stop path flightstops the path flight

Logic​

In the editorDoes
If — otherwisechecks a condition, then runs one of two lists of steps
Set variablesets a variable, adds to it, or toggles it
Send signalsends a signal to the selected objects or the whole scene
Wait, thenwaits, 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 editorChecksFields you fill in
Alwaysnothing; it is always true—
Variablea variable's valueVariable, Compare, Value
Distancehow far this event's object is from another objectObject, Compare, Threshold
Statewhich state another object is inObject, State
Visibilitywhether something is visibleObject, Expected
Chancea random chanceThreshold, as a percentage

How values are compared:

  • 3 is read as a number, true as 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.

While a state is selected, your edits go into it

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.