extends BTAction @export var radius:float = 1.0 @export var output_var: StringName = &"target_location" @export var navigatable_target:bool = false @export var stay_in_radius:bool = true var _reference_location:Vector3 = Vector3.INF func _setup() -> void: _reference_location = agent.global_position func _tick(_delta: float) -> Status: assert(_reference_location != Vector3.INF) var target_is_navigatable = true var random_location:Vector3 = Vector3.ZERO var agent_npc:NonPlayerCharacter = agent as NonPlayerCharacter if navigatable_target: assert(agent_npc) target_is_navigatable = false if not stay_in_radius: _reference_location = agent_npc.global_position var random_angle:float = randf_range(-PI, PI) random_location = _reference_location + radius * Vector3(cos(random_angle), 0, sin(random_angle)) if navigatable_target and agent_npc.is_target_navigatable(random_location): target_is_navigatable = true if target_is_navigatable: blackboard.set_var(output_var, random_location) return SUCCESS return FAILURE