@@ -37,6 +37,7 @@ func turn_left() -> void:
37
37
animated_sprite_2d .flip_h = false
38
38
39
39
func move (delta : float ) -> void :
40
+ # Change the direction of the enemy if reached a wall
40
41
if wall_ray .is_colliding ():
41
42
var collider : Node = wall_ray .get_collider () as Node2D
42
43
if not collider .is_in_group ("Player" ):
@@ -45,6 +46,7 @@ func move(delta: float) -> void:
45
46
else :
46
47
turn_right ()
47
48
49
+ # Code for player raycast used to check if an enemy spotted the player
48
50
if player_ray .is_colliding ():
49
51
var collider : Node = player_ray .get_collider () as Node
50
52
if ray_collider != collider :
@@ -81,6 +83,7 @@ func collision_check(body: Node2D) -> void:
81
83
else :
82
84
player_hit .emit (true )
83
85
86
+ # Make the spinner jump with the player when its tracking them
84
87
func _physics_process (delta : float ) -> void :
85
88
if ray_collider != null :
86
89
if ray_collider .is_in_group ("Player" ):
@@ -89,6 +92,7 @@ func _physics_process(delta: float) -> void:
89
92
90
93
move (delta )
91
94
95
+ # Speeden up the spinner if its tracking the player
92
96
func _on_player_tracked () -> void :
93
97
actual_speed = chase_speed
94
98
animated_sprite_2d .speed_scale = 2
@@ -97,6 +101,5 @@ func _on_player_tracked_stopped() -> void:
97
101
actual_speed = speed
98
102
animated_sprite_2d .speed_scale = 1
99
103
100
-
101
104
func _on_hit_box_body_entered (body : Node2D ) -> void :
102
105
collision_check (body )
0 commit comments