🏃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.