This repository has been archived on 2023-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
2DHackAndSlay/Scripts/Player/PlayerMovement.gd
2023-02-02 23:09:00 +01:00

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