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:
The State machine has a list of Behaviors, which contains States, which in turn contain Actions.
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.
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.
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.
Add lightAdds a point light to the entity
Apply forceApply a force to the attached rigid body.
Apply impulseApply an impulse to the attached rigid body.
Apply torqueApply a torque to the attached rigid body.
Arrow KeysTransitions to other states when arrow keys are pressed
Click/Tap on entity
Compare CounterCompares a counter with a value
Compare 2 CountersCompares the value of 2 counters
Camera DistancePerforms a transition based on the distance to the main camera or to a location
Copy Joint TransformCopies 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 ZoomPerforms dolly zoom
DOM ListenAdds a DOM event listener on one or many elements (specified by a query selector), and performs a transition on a given event.
Emit MessageEmits 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 FXMakes the entity emit fire. To "extinguish" the fire use the "Remove Particles" action.
HideHides an entity and its children
Hover EnterPerforms 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 ExitPerforms 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 PickListens for a picking event and performs a transition. Can only be used on HTML entities.
In BoxPerforms 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 CounterIncrements a counter with a value
In ViewPerforms a transition based on whether the entity is in a camera's frustum or not
Key DownListens for a key press and performs a transition
Key PressedListens for a key press event and performs a transition. Works over transition boundaries.
Key UpListens for a key release and performs a transition
Log MessagePrints a message in the debug console of your browser
Look AtReorients an entity so that it's facing a specific point
Mouse DownListens for a mouse button press and performs a transition
Mouse MoveListens for mouse movement and performs a transition
Mouse PressedListens for a mouse button press event and performs a transition. Works over transition boundaries.
Mouse UpListens for a mouse button release and performs a transition
MoveMoves the entity
MuteMute all sounds globally.
Next FrameTransition to a selected state on the next frame.
Pause AnimationPauses skeleton animations
Pause Particle SystemPauses particle system
Pause SoundPauses a sound.
Pause TimelinePauses the timeline.
PickListens for a picking event on the entity and performs a transition
Pick and ExitListens for a picking event on the entity and opens a new browser window
Play SoundListens for a picking event on the entity and opens a new browser window
Random TransitionPerforms a random transition
RemoveRemoves the entity from the world.
Remove LightRemoves the light attached to the entity
Remove ParticlesRemoves any particle emitter attached to the entity
Resume AnimationContinues playing a skeleton animation
RotateRotates the entity with the set angles (in degrees).
ScaleScales the entity
Set AnimationTransitions to a selected animation
Set Animation OffsetSets animation clip offset.
Background ColorSets the clear color
Set CounterSets a counter to a value
Set HTML TextSets the contents of an HTML element.
Set Light PropertiesSets various properties of a light.
Set Light RangeSets the range of a light.
Set Material ColorSets the color of a material
Set Render TargetRenders what a camera sees on the current entity's texture
Set Rigid Body Angular Velocity
Set Rigid Body PositionSet the position of the rigid body.
Set Rigid Body Rotation
Set Rigid Body Velocity
Set Timelime Time
Set Animation Time ScaleSets the time scale for the current animation
ShakeShakes the entity. Optionally performs a transition.
ShowMakes an entity visible
Smoke FXMakes the entity emit smoke. To cancel the smoke emitter use the "Remove Particles" action.
Sound Fade InFades in a sound. NOTE: will not work on iOS devices.
Sound Fade OutFades out a sound and stops it.
Start Particle System
Stop Particle System
Switch CameraSwitches to a selected camera
Toggle Full ScreenToggles fullscreen on/off. Note that in most browsers this must be initiated by a user gesture. For example, click or touch.
Toggle MuteToggles mute of all sounds globally.
Toggle Post FXEnabled/disables post fx globally
TransitionTransition to a selected state
ListenPerforms a transition on receiving a system bus message (a ping) on a specific channel
TriggerEnterTransitions when a trigger volume is entered.
TriggerLeaveTransitions when a collider is leaving the trigger volume.
Tween LightTweens the color of the light
Tween Look AtTransition the entity's rotation to face the set position.
Tween Material ColorTweens the color of a material.
Tween MoveTransition to the set location.
Tween Material OpacityTweens the opacity of a material
Tween RotateTransition to the set rotation, in angles.
Tween ScaleTransition to the set scale.
Tween Texture OffsetSmoothly changes the texture offset of the entity
UnmuteUnmute all sounds globally.
WaitPerforms 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 KeysTransitions to other states when the WASD keys are pressed