Objects in a scene can trigger various events. You can respond to these events by providing a list of actions that get executed in order. Refer to the Scenario Objects
section for what events are available for each object.
The example below shows a car object that starts a looping tween animation when its on_activate
event is triggered. All objects have an on_activate
event, which is triggered when the active
property is set to true. active
is true by default for all objects, so the event is triggered as soon as the scene starts.
{
"id": "driving_car",
"type": "model",
"path": "prius.fbx",
"position": [40, 0, 0],
"on_activate": [{
"type": "tween",
"time": 8000,
"looping": true,
"properties": {
"position": [-40, 0, 0]
}
}]
}
All actions have some shared properties.
type
- The type of action to trigger. Look before for docs on all the various types of actions.delay
- Delay the action for a given time in milliseconds.id
- (Optional) Used to reference the action later. Mostly used for canceling a delayed action.Activate a scene object. Same as calling set
with active:true
.
{ "type": "activate", "ref": "my_character" }
ref
- Reference to a scene object. Can be an array of objects, to set multiple at once. If omitted, then this
is used.Attach a scene object to another scene object.
{
"type": "attach",
"ref": "bouquet",
"target": "my_character",
"joint": "right_hand"
}
ref
- Reference to the scene object that will be attached. If omitted, then this
is used.target
- Reference to the scene object that ref
will be attached to.joint
- Joint name to attach to. If target
is a model_character
, then you must set the name of the joint.Cancel a delayed action, including a tween
action.
{ "type": "cancel", "ref": "delay_activate_my_character" }
ref
- Reference to the delayed action that will be cancelled. The action must be given an id
to be referenced.Does nothing functional. Purely for adding a message to your document. Also prints to console if you have access.
{ "type": "comment", "message": "TODO: Make sure this is deactivated." }
Deactivate a scene object. Same as calling set
with active:false
.
{ "type": "deactivate", "ref": "my_character" }
ref
- Reference to a scene object. Can be an array of objects, to set multiple at once. If omitted, then this
is used.Deactivate all trigger objects in the scene.
{ "type": "deactivate_all_triggers }
Detach a scene object from whatever it is currently attached to.
{ "type": "detach", "ref": "bouquet" }
ref
- Reference to the scene object that will be detached. If omitted, then this
is used.Hide the floating popup.
{ "type": "hide_popup" }
Play an animation of a model.
{
"type": "play_animation",
"ref": "my_character",
"animation": "sit_down",
"blend": 400,
"looping": false,
"on_complete":[]
}
ref
- Reference to either a model
or a model_character
scene object. If omitted, then this
is used.
animation
- The name of the animation to play on the model.
blend
- Blend time in milliseconds.
looping
- Loop the animation when it reaches the end.
on_complete
- Triggered when animation reaches the end.
Play a sound file.
{
"type": "play_sound",
"path": "audio/LiftMotor.mp3",
"volume": 0.5,
"delay": 1000
}
path
- Path to the sound file. Supports mp3 and wav files, however wav files must be formatted in 16bits.volume
- Adjust the volume of that playback.delay
- Wait 'x' number of milliseconds before playback begins.Set a property of a scene object.
{
"type": "set",
"ref": "my_character",
"active": true,
"scale": 2.1
}
ref
- Reference to a scene object. Can be an array of objects, to set multiple at once. If omitted, then this
is used.active : true,false
- Activate or deactivate scene object.position : [0,0,0]
- Set scene objects position to x,y,z.rotation : [0,0,0]
- Set scene objects rotation to x,y,z.Set a property for all scene objects of a given type.
{
"type": "set_all",
"object_type": "state",
"ignore": ["final_state"],
"active": false
}
object_type
- The name of the type of objects to set the properties for.ignore
- A list of object IDs to ignore when setting the properties.Show a floating popup.
{ "type": "show_popup", "path": "try_again.png" }
path
- File path to an image to show as a popup.Tween one or more properties of a scene object.
{
"type": "tween",
"ref": "bouquet",
"time": 8000,
"looping": true,
"properties": {
"position": [0, 5, 0],
"scale": 2
}
}
ref
- Reference to the scene object that will be attached. If omitted, then this
is used.time
- The duration of the tween in milliseconds.looping
- Loop the tween when it reaches the end.properties
- An object with all the properties and values that will be tweened. Properties can be any anything that the set
action can set.Vibrate a controller.
{ "type": "vibrate", "controller": "current", "time": 250 }
controller
- What controller to vibrate. Can be left
, right
or current
. current
can be used when in a triggers event, and will use what ever controller triggered the event.axis
-time
- Amount of time in milliseconds to vibrate for. Default is 100 milliseconds.Activate a particle object in the scene.
{ "type": "particle_start", "delay": 4000, "ref": "particle1" }
delay
- Wait 'x' number of milliseconds before the action begins.ref
- Reference to the particle object that will be activated in the scene.Deactivate a particle object in the scene.
{ "type": "particle_stop", "delay": 4000, "ref": "particle1" }
delay
- Wait 'x' number of milliseconds before the action begins.ref
- Reference to the particle object that will be deactivated in the scene.