Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont override actor in _ready if already defined #307

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions addons/beehave/nodes/beehave_tree.gd
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ func _ready() -> void:
if not process_thread:
process_thread = ProcessThread.PHYSICS

if actor_node_path:
actor = get_node(actor_node_path)
else:
actor = get_parent()
if not actor:
if actor_node_path:
actor = get_node(actor_node_path)
else:
actor = get_parent()

if not blackboard:
# invoke setter to auto-initialise the blackboard.
Expand Down
10 changes: 10 additions & 0 deletions test/beehave_tree_test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,13 @@ func test_blackboard_not_initialized() -> void:
tree.add_child(always_succeed)
var result = tree.tick()
assert_that(result).is_equal(BeehaveNode.SUCCESS)


func test_actor_override() -> void:
var scene = create_scene()
scene_runner(scene)
var tree = create_tree()
var actor = auto_free(Node2D.new())
tree.actor = actor
scene.add_child(tree)
assert_that(tree.actor).is_equal(actor)
Loading