16 lines
394 B
GDScript
16 lines
394 B
GDScript
extends CharacterBody2D
|
|
|
|
@export var speed = 50
|
|
|
|
func get_move_vector():
|
|
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
|
|
return input_direction
|
|
|
|
|
|
func _physics_process(delta):
|
|
# Set Velcoity to Move Vector times speed
|
|
self.velocity = get_move_vector() * speed
|
|
# Do the Physics-Calculations of the Player
|
|
self.move_and_slide()
|
|
pass
|
|
|