2024-12-28 16:34:30 +01:00
|
|
|
@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)
|
2024-12-28 16:34:30 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
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
|