Player

Kandif avatar
Kandif
plain_text
01/12/2023 4:00 PM
556 B
37
Indexable
extends KinematicBody2D

var speed = 200
var velocity = Vector2(0,0)

func _physics_process(delta) :
	velocity = Vector2.ZERO
	if Input.is_key_pressed(KEY_W):
		velocity.y = -1
	if Input.is_key_pressed(KEY_S):
		velocity.y = 1
	if Input.is_key_pressed(KEY_A):
		velocity.x = -1
	if Input.is_key_pressed(KEY_D):
		velocity.x = 1
		
	velocity = velocity.normalized() * speed
	move_and_slide(velocity)	
Editor is loading...