diff options
Diffstat (limited to 'Scenes/Entities/Enemies/Components/Movement.gd')
-rw-r--r-- | Scenes/Entities/Enemies/Components/Movement.gd | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Scenes/Entities/Enemies/Components/Movement.gd b/Scenes/Entities/Enemies/Components/Movement.gd index 0b30820..6ded026 100644 --- a/Scenes/Entities/Enemies/Components/Movement.gd +++ b/Scenes/Entities/Enemies/Components/Movement.gd @@ -1,5 +1,6 @@ extends Node + signal direction_changed @export_node_path("CharacterBody2D") var entityPath: NodePath @@ -13,11 +14,12 @@ signal direction_changed const DIRECTIONS = [Vector2.UP, Vector2.RIGHT, Vector2.DOWN, Vector2.LEFT] var CURRENT_DIRECTION = Vector2.UP +@export var timer_time: float = 3.0 @onready var MovementTimer: Timer = Timer.new() func _ready(): - MovementTimer.wait_time = 3.0 + MovementTimer.wait_time = timer_time MovementTimer.autostart = true MovementTimer.connect("timeout", Callable(_on_movement_timer_timeout)) add_child(MovementTimer) @@ -38,7 +40,11 @@ func physics_process(delta): sprite.play("right") var collision = entity.move_and_collide(entity.velocity * delta) - entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) + entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) # speed too low => no collision + + if collision: + if MovementTimer.time_left > 0: + _on_movement_timer_timeout() return collision |