diff --git a/.builds/.gitkeep b/.builds/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/enemies/police_car/police_car.gd b/enemies/police_car/police_car.gd index 467e585..065e11e 100644 --- a/enemies/police_car/police_car.gd +++ b/enemies/police_car/police_car.gd @@ -1,13 +1,25 @@ class_name PoliceCar extends CharacterBody3D +const FRAME_IDXS := 10 + @export var dot_curve: Curve var health := 10. +var frame_idx := 0 -func _physics_process(delta: float) -> void: +func _ready() -> void: + frame_idx = randi() % FRAME_IDXS + +func _update_nav_agent() -> void: %NavAgent.target_position = Player.instance.global_position +var frame_count := 0 +func _process(delta: float) -> void: + frame_count = (frame_count + 1) % FRAME_IDXS + if frame_count == frame_idx: + _update_nav_agent() + var dir := global_position.direction_to(%NavAgent.get_next_path_position()) dir.y = 0 var dot_power := dot_curve.sample(dir.dot(velocity.normalized()))