24 lines
605 B
GDScript
24 lines
605 B
GDScript
|
@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:
|
||
|
return "GetTargetLocation \"%s\" ➜%s" % [
|
||
|
target_var,
|
||
|
LimboUtility.decorate_var(target_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
|