TinyAdventure/ai/tasks/get_target_location.gd

24 lines
629 B
GDScript
Raw Permalink Normal View History

@tool
extends BTAction
@export var max_distance:float = 1.0
@export var target_var: StringName = &"target"
@export var output_var: StringName = &"target_location"
func _generate_name() -> String:
2024-12-28 18:30:23 +01:00
return "GetTargetLocation(%s) ➜ %s" % [
LimboUtility.decorate_var(target_var),
LimboUtility.decorate_var(output_var)
]
func _tick(_delta: float) -> Status:
var target_node:Node3D = blackboard.get_var(target_var)
if not is_instance_valid(target_node):
push_error("Cannot check distance to target: invalid target node!")
return FAILURE
blackboard.set_var(output_var, target_node.global_position)
return SUCCESS