Accessing nodes in the scene tree
There are several ways to access nodes in the agent’s scene tree from aBTTask.
🛈 Note: The root node of the agent’s scene tree can be accessed with thescene_root property.
WithBBNode property
@exportvarcast_param:BBNodefunc_tick(delta)->Status:varnode:ShapeCast3D=cast_param.get_value(scene_root,blackboard)
WithNodePath property
@exportvarcast_path:NodePathfunc_tick(delta)->Status:varnode:ShapeCast3D=scene_root.get_node(cast_path)
Using blackboard plan
You cancreate a blackboard variable in the editor with the typeNodePathand point it to the proper node in theBTPlayer blackboard plan. By default,anyNodePath variable will be replaced with the node instance when the blackboard is instantiatedat runtime (seeBlackboardPlan.prefetch_nodepath_vars).
extendsBTCondition@exportvarshape_var:StringName=&"shape_cast"func_tick(delta)->Status:varshape_cast:ShapeCast3D=blackboard.get_var(shape_var)
The propertyBTPlayer.prefetch_nodepath_vars should be set totrue.