19 lines
452 B
GDScript3
19 lines
452 B
GDScript3
|
extends CharacterBody2D
|
||
|
|
||
|
@export var speed = 50
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
pass # Replace with function body.
|
||
|
|
||
|
func get_input():
|
||
|
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||
|
velocity = input_direction * speed
|
||
|
|
||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
func _physics_process(delta):
|
||
|
get_input()
|
||
|
move_and_slide()
|
||
|
|
||
|
|