extends KinematicBody2D
const speed =200
func _ready():
set_process(true)
func _process(delta):
var dir = Vector2(0,0)
#здесь у меня проверка нажатие клавиш a d если нажаты то соответствевнно и анимация играется
if Input.is_action_pressed("ui_right") or Input.is_action_pressed("ui_left"):
$Anim.play("Run")
#здесь у меня проверка нажатие клавиш w s если нажаты то соответствевнно и анимация играется но тут какого то чёрта не работает
if Input.is_action_pressed("ui_down") or Input.is_action_pressed("ui_up"):
$Anim.play("Run")
if Input.is_action_pressed("ui_up"):
dir.y=-1
elif Input.is_action_pressed("ui_down"):
dir.y=1
else:
dir.y=0
if Input.is_action_pressed("ui_left"):
dir.x=-1
$Anim.flip_h=false
elif Input.is_action_pressed("ui_right"):
dir.x=1
$Anim.flip_h=true
else:
dir.x=0
if Input.is_action_pressed("ui_up") and Input.is_action_pressed("ui_down"):
dir.y=0
$Anim.play("Idle")
if Input.is_action_pressed("ui_right") and Input.is_action_pressed("ui_left"):
dir.x=0
$Anim.play("Idle")
if dir.x==0:
$Anim.play("Idle")
if dir:
translate(speed*dir*delta)