BasicStaticMovement.gd 557 B

1234567891011121314151617181920
  1. class_name BasicStaticMovement
  2. extends Node
  3. @export var auto_call := true
  4. @export var visuals: Node2D = null
  5. func _physics_process(delta: float) -> void:
  6. if auto_call:
  7. handle_movement(delta)
  8. func handle_movement(delta: float) -> void:
  9. apply_gravity(delta)
  10. if owner.is_on_floor():
  11. owner.velocity.x = lerpf(owner.velocity.x, 0, delta * 20)
  12. owner.move_and_slide()
  13. func apply_gravity(delta: float) -> void:
  14. owner.velocity.y += (Global.entity_gravity / delta) * delta
  15. owner.velocity.y = clamp(owner.velocity.y, -INF, Global.entity_max_fall_speed)