18 lines
437 B
GDScript
18 lines
437 B
GDScript
extends CharacterBody2D
|
|
|
|
|
|
const SPEED = 300.0
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
|
|
# Get the input direction and handle the movement/deceleration.
|
|
# As good practice, you should replace UI actions with custom gameplay actions.
|
|
var direction := Input.get_vector("ui_left", "ui_right","ui_up", "ui_down")
|
|
if direction:
|
|
velocity = direction * SPEED
|
|
else:
|
|
velocity = lerp(velocity, Vector2.ZERO, 0.75)
|
|
|
|
move_and_slide()
|