State Machine Component

The State Machine Component adds simple logic to the entity, similarly to scripts. The difference from scripts is that the State machine is much easier to use (no coding required!) and have many built-in Create-specific Actions.

The State Machine Component has two main panels, the panel for the Component:

…and a panel for the Behavior:

Structure

The State machine has a list of Behaviors, which contains States, which in turn contain Actions.

Read more about Finite State Machines on Wikipedia.

Behaviors

A Behavior is a collection of states. A state machine component can have several behaviors, and they are independent of each other. A Behavior can be seen as and behaves like an independent state machine.

States

Each Behavior has one or several States, but only one active state. As long as a state is active, all its Actions will also be active. All actions in inactive states are inactive. The active state can be changed by transitions in the state’s actions.

A Behavior always has one Default State which is activated when you press Play.

Actions

An Action is some logic gets executed while its State is active. Some actions executes its logic once and are done, while others execute logic once per frame. There are also Actions that just listens for events, and executes logic when the event happens.

There are many types of Actions and their effect varies a lot. See the Actions list.

Transitions: How to switch State

Many of the Actions have events, and they can trigger Transitions to other states. The simplest example is probably the WaitAction. When the Action starts executing, it sets a timer for a number of seconds. When the timer is up, it can transition to some other State.

Actions list

Add light

Adds a point light to the entity

Apply force

Apply a force to the attached rigid body.

Apply impulse

Apply an impulse to the attached rigid body.

Apply torque

Apply a torque to the attached rigid body.

Arrow Keys

Transitions to other states when arrow keys are pressed

Click/Tap on entity

Compare Counter

Compares a counter with a value

Compare 2 Counters

Compares the value of 2 counters

Camera Distance

Performs a transition based on the distance to the main camera or to a location

Copy Joint Transform

Copies a joint's transform from another entity, and applies it to this entity. This entity must be a child of an entity with an animation component

Dolly Zoom

Performs dolly zoom

DOM Listen

Adds a DOM event listener on one or many elements (specified by a query selector), and performs a transition on a given event.

Emit Message

Emits a message (a ping) to a channel on the bus. Messages can be listened to by the Listen action, or by scripts using the SystemBus.addListener(channel, callback) function.

Fire FX

Makes the entity emit fire. To "extinguish" the fire use the "Remove Particles" action.

Hide

Hides an entity and its children

Hover Enter

Performs a transition based on whether an entity is inside a user defined box volume or not.The volume is defined by setting two points which, when connected, form a diagonal through the box volume.

Hover Exit

Performs a transition based on whether an entity is inside a user defined box volume or not.The volume is defined by setting two points which, when connected, form a diagonal through the box volume.

HTML Pick

Listens for a picking event and performs a transition. Can only be used on HTML entities.

In Box

Performs a transition based on whether an entity is inside a user defined box volume or not.The volume is defined by setting two points which, when connected, form a diagonal through the box volume.

Increment Counter

Increments a counter with a value

In View

Performs a transition based on whether the entity is in a camera's frustum or not

Key Down

Listens for a key press and performs a transition

Key Pressed

Listens for a key press event and performs a transition. Works over transition boundaries.

Key Up

Listens for a key release and performs a transition

Log Message

Prints a message in the debug console of your browser

Look At

Reorients an entity so that it's facing a specific point

Mouse Down

Listens for a mouse button press and performs a transition

Mouse Move

Listens for mouse movement and performs a transition

Mouse Pressed

Listens for a mouse button press event and performs a transition. Works over transition boundaries.

Mouse Up

Listens for a mouse button release and performs a transition

Move

Moves the entity

Mute

Mute all sounds globally.

Next Frame

Transition to a selected state on the next frame.

Pause Animation

Pauses skeleton animations

Pause Particle System

Pauses particle system

Pause Sound

Pauses a sound.

Pause Timeline

Pauses the timeline.

Pick

Listens for a picking event on the entity and performs a transition

Pick and Exit

Listens for a picking event on the entity and opens a new browser window

Play Sound

Listens for a picking event on the entity and opens a new browser window

Random Transition

Performs a random transition

Remove

Removes the entity from the world.

Remove Light

Removes the light attached to the entity

Remove Particles

Removes any particle emitter attached to the entity

Resume Animation

Continues playing a skeleton animation

Rotate

Rotates the entity with the set angles (in degrees).

Scale

Scales the entity

Set Animation

Transitions to a selected animation

Set Animation Offset

Sets animation clip offset.

Background Color

Sets the clear color

Set Counter

Sets a counter to a value

Set HTML Text

Sets the contents of an HTML element.

Set Light Properties

Sets various properties of a light.

Set Light Range

Sets the range of a light.

Set Material Color

Sets the color of a material

Set Render Target

Renders what a camera sees on the current entity's texture

Set Rigid Body Angular Velocity

Set Rigid Body Position

Set the position of the rigid body.

Set Rigid Body Rotation

Set Rigid Body Velocity

Set Rotation

Set Timelime Time

Set Animation Time Scale

Sets the time scale for the current animation

Shake

Shakes the entity. Optionally performs a transition.

Show

Makes an entity visible

Smoke FX

Makes the entity emit smoke. To cancel the smoke emitter use the "Remove Particles" action.

Sound Fade In

Fades in a sound. NOTE: will not work on iOS devices.

Sound Fade Out

Fades out a sound and stops it.

Sprite Animation

Start Particle System

Start Timeline

Stop Particle System

Stop Sound

Stop Timeline

Switch Camera

Switches to a selected camera

Toggle Full Screen

Toggles fullscreen on/off. Note that in most browsers this must be initiated by a user gesture. For example, click or touch.

Toggle Mute

Toggles mute of all sounds globally.

Toggle Post FX

Enabled/disables post fx globally

Transition

Transition to a selected state

Listen

Performs a transition on receiving a system bus message (a ping) on a specific channel

TriggerEnter

Transitions when a trigger volume is entered.

TriggerLeave

Transitions when a collider is leaving the trigger volume.

Tween Light

Tweens the color of the light

Tween Look At

Transition the entity's rotation to face the set position.

Tween Material Color

Tweens the color of a material.

Tween Move

Transition to the set location.

Tween Material Opacity

Tweens the opacity of a material

Tween Rotate

Transition to the set rotation, in angles.

Tween Scale

Transition to the set scale.

Tween Texture Offset

Smoothly changes the texture offset of the entity

Unmute

Unmute all sounds globally.

Wait

Performs a transition after a specified amount of time. A random time can be set, this will add between 0 and the set random time to the specified wait time.

WASD Keys

Transitions to other states when the WASD keys are pressed