14 lines
351 B
GDScript
14 lines
351 B
GDScript
extends CharacterBody2D
|
|
class_name Player
|
|
|
|
@export var speed = 400
|
|
|
|
func get_input():
|
|
var input_direction : Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
|
velocity = input_direction * speed
|
|
if input_direction.x:
|
|
$Sprite.flip_h = (input_direction.x < 0)
|
|
|
|
func _physics_process(_delta):
|
|
get_input()
|
|
move_and_slide() |