Skip to content

Commit b5fcc35

Browse files
committed
Guard script: Do ALERTED state change only once
Move the change (stopping the movement) from the process function to the state setter.
1 parent 05a3e45 commit b5fcc35

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • scenes/game_elements/characters/enemies/guard/components

scenes/game_elements/characters/enemies/guard/components/guard.gd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,21 @@ func _process(delta: float) -> void:
178178
guard_movement.set_destination(target_position)
179179
else:
180180
guard_movement.stop_moving()
181+
guard_movement.move()
182+
State.WAITING:
183+
guard_movement.move()
184+
State.DETECTING:
185+
guard_movement.move()
181186
State.INVESTIGATING:
182187
guard_movement.set_destination(last_seen_position)
188+
guard_movement.move()
183189
State.RETURNING:
184190
if breadcrumbs:
185191
var target_position: Vector2 = breadcrumbs.back()
186192
guard_movement.set_destination(target_position)
187193
else:
188194
state = State.PATROLLING
189-
State.ALERTED:
190-
guard_movement.stop_moving()
191-
192-
guard_movement.move()
195+
guard_movement.move()
193196

194197
if state != State.ALERTED:
195198
_update_player_awareness(delta)
@@ -288,6 +291,7 @@ func _set_state(new_state: State) -> void:
288291
player_awareness.ratio = 1.0
289292
player_awareness.tint_progress = Color.RED
290293
player_awareness.visible = true
294+
guard_movement.stop_moving()
291295
State.INVESTIGATING:
292296
breadcrumbs.push_back(global_position)
293297
State.WAITING:

0 commit comments

Comments
 (0)