20 lines
559 B
GDScript
20 lines
559 B
GDScript
extends BTCondition
|
|
class_name BTHasArrived
|
|
|
|
func tick(tick: Tick) -> int:
|
|
var npc = tick.actor
|
|
var tgt = npc.get_meta("target_loc")
|
|
var point = npc.get_meta("path_point")
|
|
var npc_pos = npc.global_transform.origin
|
|
# print("target: ", tgt, " point: ", point, " pos: ", npc_pos)
|
|
if point.distance_to(tgt) < 0.2:
|
|
# print("arrived1")
|
|
npc.set_meta("path_valid", 0.0)
|
|
return OK
|
|
if npc_pos.distance_to(tgt) < 0.4:
|
|
# print("arrived2")
|
|
npc.set_meta("path_valid", 0.0)
|
|
return OK
|
|
# print(npc.name, " distance: ", npc_pos.distance_to(tgt))
|
|
return FAILED
|