๐Behavior Nodes
Last updated
Last updated
A powerful feature of Bonfire is its Node system. Nodes are individual pieces of functionality that, when chained together, allow creators to build unique and customizable experiences. Bonfire supports a variety of Behavior Nodes that are grouped into Causes, Effects, and Modifiers.
Nodes are made up of sockets, transitions, and properties. Sockets are the white circles positioned at the top and bottom of a Node. The number of sockets a Node has depends on its purpose and function.
Transitions are formed by connecting sockets of different Nodes. These transitions direct the execution flow and are represented by solid white lines between Nodes. Nodes can be executed in sequence, one after another, in parallel, at the same time, or both.
Nodes have a unique set of configurable properties. When adding a Node to the tree in the Behaviors Panel, Bonfire assigns default modifiable values to each property.
Nodes are tied to a Spark. Before adding a Behavior Node, creators must select a Spark from the Map Editor, Map Explorer, Entities Panel, Symbols Panel, or the Spark dropdown in the Behaviors panel. Once a Spark is selected, a list of available Causes and Effects will appear in a dropdown.
Although Bonfire comes with a set of prebuilt Behavior Nodes, creators could use the SparkSDK to create custom Causes and Effects unique to a project.
A Cause is an input to a Spark that represents a condition or action within a Chapter. Examples of Causes include the starting โconditionโ of a Chapter upon start or a player's triggering โactionโ on a given Spark. When these conditions or actions are met, all Effects and Modifiers connected to the Cause will be triggered.
Approached
The โApproachedโ Cause is triggered by movement into a defined circumference around a given Spark. The following are modifiable Approached characteristics:
Attacked
The โAttackedโ Cause is assigned to a Spark that receives the impact of actions taken by a player. To see a visual response, the Cause needs to be connected to an Effect, which might be a modification of the Health valueโa measure of physical capacityโor an Animation (i.e., death, attack). The user in the experience initiates actions based on keyboard or VR controller actions. The keyboard key to initiate an attack is the letter Q.
Collided
The โCollidedโ Cause triggers when a Spark or player either begins or stops touching the Spark associated with the โCollidedโ Cause.
The following instructions describe using the โCollidedโ Cause and configuring its settings.
Prerequisites
Please ensure creators have downloaded Bonfireโs Low-Poly Animals asset pack to follow this tutorial.
In the Spark Browser, navigate to the Low-Poly โ Animals directory.
Drag and drop the Buffalo Spark into the Map Editor panel from the Animals directory.
Figure 1
After dropping the Buffalo Spark, it will be highlighted in the Map Editor panel and selected in the Behavior and Traits panels.
Figure 2
For the Buffalo Spark to collide, ensure that the 'Is Collidable' option is selected in the Traits panel of the Buffalo Spark. If this option is not selected, the โCollidedโ Cause will have no effect.
Figure 3
Next, add the โCollidedโ Cause. In the Behaviors panel, ensure that the Buffalo Spark is selected from the Sparks dropdown, and select the 'Collided' Cause from the Causes dropdown.
Figure 4
Figure 5
Now that the โCollidedโ Cause has been added, let's log a message to the Console when the player collides with the Buffalo.
First, ensure that the 'On Enter' and 'With Player' are the only options selected from the โCollidedโ Cause.
Next, go to the Modifiers Dropdown in the Behaviors panel and select 'Debug' Modifier.
Figure 6
Figure 7
To trigger the โDebugโ Modifier after the Buffaloโs 'Collided' Cause is triggered, a connection has to be made between the output socket of the Buffaloโs Cause Collider and the input socket of the โDebugโ Modifier. Input sockets are the white circles at the top of a node, and output sockets are the white circles at the bottom of a node.
Figure 8
In the 'Message' field of the โDebugโ Modifier, enter 'Player has collided with me.' This message will appear in the Console panel when the โDebugโ Modifier triggers (i.e. when the player collides with the Buffalo).
To test the collision, clear all messages from the Console panel and enter the Map Explorer panel.
Use the arrow keys to move the player towards the Buffalo. As soon as the player touches the Buffalo, 'Player has collided with me' will appear in the Console panel. Creators will note that Bonfire outputs other messages relating to the 'Collided' Cause to the Console panel for debugging purposes.
Figure 9
Grabbed
The โGrabbedโ Cause is set on a Spark as the input that allows a user to interact (hold, move) with a given Spark.
Interacted
The โInteractedโ Cause is triggered when the player interacts with the Spark associated with the โInteractedโ Cause.
Audio
The Audio Effect is accessible for Sparks and includes audio files as part of their supplemental data.
Modify
The โModifyโ Effect modifies Traits on the Spark it is attached to.
Animation Play
The โAnimation Playโ Effect changes the animation on a Spark. The animation will only play if the Spark has animations attached to it and the 'Do Animation' Trait is enabled on the Spark.
Animation Stop
The โAnimation Stopโ Effect stops the animation on a Spark. The animation will only stop if the Spark has animations attached to it and the 'Do Animation' Trait is enabled on the Spark. Highlight
The โHighlightโ Effect emphasizes the Spark attached to it, with a fade-in and a fade-out effect.
Move
The โMoveโ Effect changes the โPositionโ Trait and the โAltitudeโ Trait of the Spark attached.
Rotate
The โRotateโ Effect modifies the โRotationโ Trait of the Spark attached to it.
Converse
The โConverseโ Effect represents conversation text that appears above the Spark.
Force Grab
The โForce Grabโ Effect compels the player to grab any Grabbable Spark directly in front of them.
Force Drop
The โForce Dropโ Effect makes the player release any Spark they are currently holding.
Attach On
The โAttach Onโ Effect attaches the Spark to another Spark or onto a player.
Attach Off
The โAttach Offโ Effect detaches the Spark from its current attachment.
Submesh
The โSubmeshโ Effect allows the player to toggle the visibility of specific parts of a Sparkโs body, provided the Spark's 3D object has multiple submeshes.
Change Book
The โChange Book Modifier' will load the Book linked to a given share code. The state of the current Book is saved and unloaded before loading the new Book.
Blackout
The โChange Book Modifier' will load the Book linked to a given share code. The state of the current Book is saved and unloaded before loading the new Book.
Change Chapter
When triggered, the โChange Chapterโ Modifier loads the selected Chapter. The state of the current Chapter is saved and unloaded before loading the new Chapter.
Comment
The Comment Modifier is a basic text box for creator notes, which can be placed anywhere in the Behavior Tab panel. The text box automatically expands based on the length of the comment.
Debug
When triggered, the โDebugโ Modifier logs a message to the Console panel.
Delay
The โDelayโ Modifier delays triggering the node connected to its output socket.
Spawn Spark
The โSpawn Sparkโ Modifier creates a clone of an existing Spark within the current Chapter when it is triggered.
Exit Book
The 'Exit Book' Modifier terminates the game session and exits the player from the game when activated.
Random
The โRandomโ Modifier will randomly trigger a Node connected to one of its two output sockets.
Chapter Started
The 'Chapter Started' Modifier is automatically triggered, activating the connected Nodes upon the start of a Chapter. This occurs when the player begins the scene or Chapter, or when Play Mode is enabled in the builder. It is useful for executing Nodes that need to be triggered at the beginning of a Chapter.
Toggle
The โToggleโ Modifier alternates, triggering the Nodes connected to each of its two output sockets. This could be used for on/off, open/close, visible/hidden behaviors.
Stop Audio Channel
The 'Stop Audio Channel' Modifier forcibly stops playback of a specified Audio Spark when triggered.
Ember
The 'Ember' Modifier activates the custom ember script specified in the input box.
After selecting the โCollidedโ Cause, click the icon next to the Causes dropdown to add the Collided Node to the Behaviors panel.
Once selected, click on the icon next to the Modifiers dropdown to add it to the Behavior panel.
Distance
Distance from the Spark associated with the โApproachedโ Cause, measured in meters. If the player or specified Spark is within this distance, the โApproachedโ Cause will trigger.
Player
If enabled, the player will trigger the โApproachedโ Cause.
Spark
If enabled, the selected Spark will trigger the โApproachedโ Cause.
One Shot
If enabled, the โApproachedโ Cause will only trigger once.
One Shot
If enabled, the โCollidedโ Cause will only trigger once.
On Enter
Triggers when a Spark or player touches the Spark associated with the โCollidedโ Cause.
On Exit
Triggers when a Spark or player has stopped touching the Spark associated with the โCollidedโ Cause.
With Spark
On Enter/On Exit is triggered by the selected Spark.
With Player
On Enter/On Exit is triggered by the player.
Clip
Audio clip selection. The selection comprises all audio files added as supplemental data during the Spark creation.
State
Changes the state of the audio clip when the Effect triggers:
Play - Plays the audio clip.
Pause - Pauses the audio clip.
Stop - Stop the audio clip.
Volume
Sets the volume of the audio clip. The volume is normalized, meaning the range can only be set from 0 (mute) to 1 (maximum volume).
Solo
Only the selected audio clip will play when enabled, stopping other audio clips. When disabled, the audio clip will play regardless of different audio clips.
Is Visible
If enabled, the โIs Visibleโ Trait will be enabled when the Modify Effect is triggered; otherwise, the Trait will be disabled.
Use Physics
If enabled, the โUse Physicsโ Trait will be enabled when the Modify Effect is triggered; otherwise, the Trait will be disabled.
Is Collidable
If enabled, the โIs Collidableโ Trait will be enabled when the Modify Effect is triggered; otherwise, the Trait will be disabled.
Is Grabbable
If enabled, the โIs Grabbableโ Trait will be enabled when the Modify Effect is triggered; otherwise, the Trait will be disabled.
Is Interactable
If enabled, the โIs Interactableโ Trait will be enabled when the Modify Effect is triggered; otherwise, the Trait will be disabled.
Do Animation
If enabled, the Sparkโs Animation will be enabled when the Modify Effect is triggered; otherwise, it will be disabled.
Altitude
If a decimal value is entered, the Sparkโs Altitude Trait updates to match the value in the input box when the Modify Effect is triggered.
Position
If a decimal value is entered, the Sparkโs X and Y Position Traits update to match the values in the input boxes when the Modify Effect is triggered.
Rotation
If a decimal value is entered, the Sparkโs X, Y, and Z Rotation Traits update to match the values in the input boxes when the Modify Effect is triggered.
Scale
If a decimal value is entered, the Sparkโs Scale Trait updates to match the value in the input box when the Modify Effect is triggered.
Color
If a decimal value is entered, the Sparkโs R, G, B, and Alpha color Traits update to match the values in the input boxes when the Modify Effect is triggered.
Do Loop
If enabled, the selected clip will loop.
Clip
This is the animation that will play when the Animation Effect triggers.
Enabled
If enabled, the Spark will be emphasized.
Altitude
Raises or lowers the Spark to the entered altitude.
Position
Moves the Spark to the entered x and y positions.
x
Sets the Sparkโs rotation along the x-axis.
y
Sets the Sparkโs rotation along the y-axis.
z
Sets the Sparkโs rotation along the z-axis.
Time
The duration of the text conversation displayed on the screen is represented in seconds. When this time duration is reached, the text conversation disappears.
Message
The conversation text will be displayed above the Spark.
Type
Attachment Options:
Spark - Attach to another Spark. A new โParentโ dropdown will appear to specify which Spark to attach it to.
Player_Head - Attaches the Spark to the playerโs head.
Player_Hand_L - Attaches the Spark to the playerโs left hand.
Player_Hand_R - Attaches the Spark to the playerโs right hand.
Parent
This field appears only if โSparkโ is selected in the Type dropdown. It specifies which Spark the currently selected Spark should be attached to.
Offset Position
Specifies the X, Y, and Z offset positions from the center of the attachment point.
Offset Rotation
Specifies the X, Y, and Z offset rotations from the center of the attachment point.
SubMesh
Provides options to select specific parts of a Sparkโs body to toggle visibility.
Visible
Indicates whether to toggle the visibility of the part selected in the SubMesh dropdown when this Effect is triggered.
Share Code
The share code of the Book to load.
Type
FadeOut: Applies a fade-out effect to the playerโs screen when this Modifier is triggered.
FadeIn: Applies a fade-in effect to the playerโs screen when this Modifier is triggered.
FadeOutThenIn: Applies a fade-out effect followed by a fade-in effect after a specified duration in seconds.
Chapter
The Chapter to load. The selection includes the current Chapter and the next linked Chapter, as defined in the Chapter tree.
Message
The message logged to the Console panel.
Trigger button
The Trigger button allows creators to trigger the โDebugโ Modifier manually. If a node is connected to one of the output sockets of the โDebugโ Modifier, it will execute after the Trigger button is pressed.
Seconds
Number of seconds to wait before the node connected to the output socket is triggered.
Template
A dropdown list to select an existing Spark in the Chapter to clone.
Position
The X, Y, and Z position to where the cloned Spark will spawn.
Rotation
The X, Y, Z rotation of the cloned Spawn when it spawns
Channel Name
Specifies the audio channel that the creator wants to stop playing.
Instance ID
Specifies the name or ID of the Ember script to be triggered when the 'Ember' Modifier is activated.
Open
Button to open or view the Ember script.