Skip to content

Commit

Permalink
Doc: Add accessing-nodes page
Browse files Browse the repository at this point in the history
  • Loading branch information
limbonaut committed Feb 17, 2024
1 parent e7f1d3a commit 487c008
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions doc/source/getting-started/accessing-nodes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.. _accessing_nodes:

Accessing nodes in the scene tree
=================================

There are several ways to access nodes in the agent's scene tree (agent is the owner of :ref:`BTPlayer<class_BTPlayer>` node):

1. You can export a :ref:`BBNode<class_BBNode>` variable:

.. code:: gdscript
@export var cast: BBNode
func _tick(delta) -> Status:
var node: ShapeCast3D = cast.get_value(agent, blackboard)
2. You can export a ``NodePath``

.. code:: gdscript
@export var cast_path: NodePath
var _shape_cast: ShapeCast3D
func _setup() -> void:
_shape_cast = agent.get_node(cast_path)
3. You can :ref:`create a blackboard variable<editing_plan>` in the editor with the type ``NodePath``
and point it to the proper node in the :ref:`BTPlayer<class_BTPlayer>` blackboard plan.

.. code:: gdscript
extends BTCondition
@export var shape_var: String = "shape_cast"
func _tick(delta) -> Status:
var shape_cast: ShapeCast3D = blackboard.get_var(shape_var)
The property :ref:`BTPlayer.prefetch_nodepath_vars<class_BTPlayer_property_prefetch_nodepath_vars>` should be set to ``true``.
2 changes: 2 additions & 0 deletions doc/source/getting-started/using-blackboard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Here's an example of how you can interact with the :ref:`Blackboard<class_Blackb
**🛈 Note:** The variable doesn't need to exist when you set it.

.. _editing_plan:

Editing the Blackboard Plan
---------------------------

Expand Down
1 change: 1 addition & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ the other any time. For more information on this topic, see :ref:`gdextension`.
getting-started/using-blackboard
getting-started/gdextension
getting-started/c-sharp
getting-started/accessing-nodes
getting-started/featured-classes

.. toctree::
Expand Down

0 comments on commit 487c008

Please sign in to comment.