Pierwsze_Stale

TaktycznyBocian avatar
TaktycznyBocian
Plain Text
11/24/2022 5:24 PM
495 B
33
Indexable
Never
extends KinematicBody2D

var speed = 200

var velocity = Vector2()

func _physics_process(_delta):
	velocity = Vector2()
	if Input.is_action_pressed("ui_right"):
		velocity.x = velocity.x + 1
	if Input.is_action_pressed("ui_left"):
		velocity.x = velocity.x - 1
	if Input.is_action_pressed("ui_down"):
		velocity.y = velocity.y + 1
	if Input.is_action_pressed("ui_up"):
		velocity.y = velocity.y - 1
	velocity = velocity.normalized() * speed
	velocity = move_and_slide(velocity)
Editor is loading...