summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Components/Movement.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-04-22 16:34:25 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-04-22 16:34:25 +0200
commitc8a316e4b8987dad963656a34665fa0e23dedcb1 (patch)
tree569af4b4f37d21079b6aedfad5164e94b50b6cb8 /Scenes/Entities/Enemies/Components/Movement.gd
parentf27937e6e9b6a7146dd09fc711d2d293ecf5abbf (diff)
update
Diffstat (limited to 'Scenes/Entities/Enemies/Components/Movement.gd')
-rw-r--r--Scenes/Entities/Enemies/Components/Movement.gd10
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