TinyAdventure/ai/tasks/find_target_by_name.gd

22 lines
467 B
GDScript
Raw Permalink Normal View History

2024-12-09 21:05:09 +01:00
@tool
extends BTAction
@export var target_name: String = ""
@export var output_var: StringName = &"target"
func _generate_name() -> String:
return "FindTargetByName \"%s\"%s" % [
target_name,
LimboUtility.decorate_var(output_var)
]
func _tick(_delta: float) -> Status:
var node:Node3D = agent.get_tree().root.find_child(target_name, true, false) as Node3D
if node == null:
return FAILURE
blackboard.set_var(output_var, node)
return SUCCESS