Untitled

 avatar
Kandif
plain_text
2 years ago
433 B
5
Indexable
Never
extends KinematicBody2D
 
var speed = 200
 
var velocity = Vector2()
 
func _physics_process(_delta):
	velocity = Vector2(0,0)
	if Input.is_key_pressed(KEY_D):
		velocity.x += 1
	if Input.is_key_pressed(KEY_A):
		velocity.x -= 1
	if Input.is_key_pressed(KEY_W):
		velocity.y -= 1
	if Input.is_key_pressed(KEY_S):
		velocity.y += 1		
 
	velocity = velocity.normalized() * speed
	velocity = move_and_slide(velocity)