|
@@ -23,8 +23,8 @@ func attack(from: Vector2, angle: float):
|
|
|
_current_state = State.WALKING
|
|
|
|
|
|
|
|
|
-func _physics_process(delta):
|
|
|
- var collision = move_and_collide(velocity * delta, false)
|
|
|
+func _physics_process(delta: float):
|
|
|
+ var collision = _move(delta)
|
|
|
_collide_and_react(collision)
|
|
|
|
|
|
|
|
@@ -45,6 +45,13 @@ func _die():
|
|
|
queue_free()
|
|
|
|
|
|
|
|
|
+func _move(delta: float) -> KinematicCollision2D:
|
|
|
+ if _current_state == State.WALKING or _current_state == State.RUNNING:
|
|
|
+ return move_and_collide(velocity * delta, false)
|
|
|
+ else:
|
|
|
+ return move_and_collide(Vector2.ZERO, false)
|
|
|
+
|
|
|
+
|
|
|
func _collide_and_react(collision: KinematicCollision2D) -> void:
|
|
|
if collision == null:
|
|
|
return
|