33 lines
797 B
GDScript3
Raw Normal View History

2020-01-26 16:31:20 +01:00
extends NPC
2020-01-26 22:31:48 +01:00
const diffPerSecond = 5
var _arrived_distance_threshold = 0.1
2020-01-26 16:31:20 +01:00
var _interactArea: Area
2020-01-26 22:31:48 +01:00
var _navPath: Path
var _followPath: PathFollow
var _current_nav_index = 0
2020-01-26 16:31:20 +01:00
func _ready():
#Logger.set_logger_level(Logger.LOG_LEVEL_FINE)
2020-01-26 22:31:48 +01:00
_followPath = get_node("../") as PathFollow
assert(null != _followPath)
2020-01-26 16:31:20 +01:00
2020-01-26 22:31:48 +01:00
_navPath = get_node("../../") as Path
assert(null != _navPath)
2020-01-26 16:31:20 +01:00
var _interactArea = get_node("InteractArea") as Area
assert(null != _interactArea)
_interactArea.connect("area_entered", self, "_on_area_entered")
func _process(_delta):
# TODO: movement
#if current_target: # should not be needed -> handled per navigation path
2020-01-26 22:31:48 +01:00
_followPath.offset += diffPerSecond * _delta
2020-01-26 16:31:20 +01:00
func _on_area_entered (area: Area):
if area.is_in_group("FactoryEntry"):
2020-01-26 16:37:38 +01:00
# despawn
2020-01-26 22:31:48 +01:00
queue_free()