To share data between different tasks and states, we employ a feature known as the :ref:`Blackboard<class_Blackboard>`.
The :ref:`Blackboard<class_Blackboard>` serves as a central repository where tasks and states can store and retrieve named variables,
allowing for seamless data interchange. Each instance of a behavior tree or a state machine gets its own dedicated :ref:`Blackboard<class_Blackboard>`. It has the capability to store various data types,
including objects and resources.
Using the :ref:`Blackboard<class_Blackboard>`, you can easily share data in your behavior trees, making the tasks in the behavior tree more flexible.
Accessing the Blackboard in a Task
----------------------------------
Every :ref:`BTTask<class_BTTask>` has access to the :ref:`Blackboard<class_Blackboard>`, providing a
straightforward mechanism for data exchange.
Here's an example of how you can interact with the :ref:`Blackboard<class_Blackboard>` in GDScript:
..code:: gdscript
@export var speed_var: String = "speed"
func _tick(delta: float) -> Status:
# Set the value of the "speed" variable:
blackboard.set_var(speed_var, 200.0)
# Get the value of the "speed" variable, with a default value of 100.0 if not found:
var speed: float = blackboard.get_var(speed_var, 100.0)
# Check if the "speed" variable exists:
if blackboard.has_var(speed_var):
# ...
..
**🛈 Note:** The variable doesn't need to exist when you set it.