TinyAdventure/ai/tasks/calc_distance_to_location.gd

20 lines
566 B
GDScript
Raw Permalink Normal View History

@tool
extends BTAction
@export var target_location_var: StringName = &"target_location"
@export var output_var: StringName = &"location_distance"
func _generate_name() -> String:
2024-12-28 18:30:23 +01:00
return "CalcDistanceToLocation(%s) ➜ %s" % [
LimboUtility.decorate_var(target_location_var),
LimboUtility.decorate_var(output_var)
]
func _tick(_delta: float) -> Status:
var target_location:Vector3 = blackboard.get_var(target_location_var)
var distance:float = (target_location - agent.global_position).length()
blackboard.set_var(output_var, distance)
return SUCCESS