Brainevents and State Brainboxes

Brainevents activate gameplay features and logic in a sequential order that is determined by the object or player action. State Brainboxes allow you to activate the Brainevents that they are attached to, and contain predefined gameplay features and functionalities such as animation, data, motion, and outcomes.

The following example is a 2D character asset that contains multiple Brainevents and State Brainboxes:

When the asset is created in the game, the Idle Brainevent activates, which in turn activates the Idle State Brainbox that plays an animation. After the player presses a movement key, the Idle Brainevent deactivates and the Run Brainevent activates along with the Run State Brainbox that moves the character while playing an animation. After the player releases the movement key, the Run Brainevent deactivates and the Idle Brainevent activates. The character stops moving and plays its Idle animation.
Brainevents

There are two ways you can add a Brainevent to an asset.

To add a Brainevent to an asset from the Asset panel:

  1. In a World workspace and in the Asset panel, select an asset.
  2. In the Options panel, click the Add Brainevent button on the bottom.
  3. In the Name field, enter a new name for the Brainevent.

To add or edit a Brainevent from the asset’s Node Map, double-click the asset in the asset panel and do any of the following:

  • To add a Brainevent in the asset’s Node Map, click the + button on the Start node. A New Event appears on the Start node
  • To type a new name for the Brainevent, click the Brainevent’s name on the Start Node.
  • To view or change the Brainevent’s attributes in the Options panel on the right, select the Start node.

Brainevent Output

After you create a Brainevent, a new output with the Brainevent name appears on the asset’s start node.

  • To allow the Brainevent to activate nodes, connect the Brainevent output to the nodes of your choice.
  • When the Brainevent activates, it will activate all of its connected nodes.

Priority

Since only one Brainevent can be active at a time, you can enter a value in a Brainevent’s Priority attribute to determine how Brainevents can activate and deactivate one another.

  • During an active Brainevent, only Brainevents with the same or higher priority value will be able to activate.
  • For example, if the active Brainevent’s priority is 2, then only other Brainevents with a priority of 2 or higher can activate. Brainevents that contain a priority lower than 2, will not be able to activate.

The following is an example of multiple Brainevents with different priorities that change the color of the asset:

After the Green event activates, the Red and Blue events deactivate and will not be able to activate again until the Green event deactivates. The Red and Blue Brainevents will interrupt one another when either activates.

Self-Interruptible

  • Select the Self-Interruptible checkbox to allow the Brainevent to activate even if it is already active.
  • Clear the checkbox to prevent the Brainevent from activating again when it is already active.
State Brainboxes

State Brainboxes add predefined functionality and outcomes to an asset and can transition to other Brainevents.

To add a State Brainbox to a Brainevent, navigate to the Options panel and next to a Brainevent name, click the Add Brainbox icon and select one of the following State Brainboxes:

Name Icon Description Transition
AI Simple Applies the following to an asset:

  • Automatic movement along the X axis and changes its direction after it collides with another object or approaches the end of a platform.
  • Character detection that allows the asset to detect a character then move towards the characters location to attack it.
None
AI Advanced Applies the following to an asset:

  • Automatic movement along the X axis and changes its direction after it collides with another object or approaches the end of a platform.
  • Attack frequency that makes the asset automatically attack periodically.
None
Idle Plays a looping animation when the asset is created or spawned in the game Initial Event – Select the Brainevent you want to activate when the asset is created or spawns in the game.
Run Allows the player to press the A and D keyboard buttons to make the asset move left or right while playing an animation and sound. The asset will always face the movement direction and flips when the movement direction changes. Idle Event – Select a Brainevent that contains an Idle State Brainbox or a Brainevent you want to activate after the player releases the run control.
Jump Allows the player to press the X keyboard button to launch the asset up in the Y direction while playing an animation and sound.

Requires the asset’s physics to be Dynamic.
Fall Event – Select a Brainevent that contains a Fall State Brainbox or a Brainevent you want to activate when the character begins to fall.
Fall Plays an animation and sound when the asset begins to fall in the Y direction.

Requires the asset’s physics to be Dynamic.
None – This Brainevent stays active until a different one activates.
Land Plays an animation and sound when the asset lands on a surface.

Requires the asset’s physics to be Dynamic. Requires the surface asset’s physics to be any type of physics.
Event on End – Select a Brainevent that you want to activate after the animation ends.
Attack Allows the player to press the Z keyboard button, or another specified button to make the asset play an animation and create a hitbox that applies damage to other assets with health. Event on End – Select a Brainevent that you want to activate after the animation ends.
Damage Applies health to an asset and allows it to and take damage from other assets. Also plays an animation and sound when the asset takes damage.

Event on End – Select a Brainevent that you want to activate after the animation ends.

Death Event – Select a Brainevent that contains the Death State Brainbox or a Brainevent you want to activate when the Character’s health reaches 0.

 

Death Plays an animation and sound to signify the death or defeat of the asset. None – This Brainevent stays active until a different one activates.

To view the nodes associated with a State Brainbox, double-click an asset in the asset panel.
Below is an example of the Run State Brainbox and the Idle State Brainbox.