bitbrain / beehave

🐝 behavior tree AI for Godot Engine
https://bitbra.in/beehave
MIT License
1.85k stars 116 forks source link

Setting `actor_node_path` to a non-parent throws an error #341

Open rxlecky opened 3 months ago

rxlecky commented 3 months ago

Godot version: 4.2.2 Beehave version: 2.8.0

Describe the bug When setting the actor via the actor_node_path property to a node that is not the parent of the behaviour tree node, the following error is thrown:

E 0:00:00:0785   beehave_tree.gd:38 @ @actor_node_path_setter(): Node not found: "../.." (relative to "Node").
  <C++ Error>    Method/function failed. Returning: nullptr
  <C++ Source>   scene/main/node.cpp:1651 @ get_node()
  <Stack Trace>  beehave_tree.gd:38 @ @actor_node_path_setter()

This happens because the setter is called before the node is added to the scene tree so the get_node() call fails to fetch nodes higher up in the tree. This issue doesn't happen when setting the actor via the actor property.

To Reproduce Steps to reproduce the behaviour:

  1. Create and populate a behaviour tree
  2. Set its actor_node_path property to a node that is not its parent
  3. Play the scene
  4. See error

Reproduction project BeehaveIssueMRP.zip