I figured out how to use animations, and moving, but how can it switch to idle when doing nothing?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mattryan26

extends KinematicBody2D

export(int) var speed = 80.0

onready var _animation_player = $AnimationPlayer

func _process(_delta):
if Input.is_action_pressed(“ui_left”):

func _physics_process(delta):
var velocity = Vector2.ZERO
if Input.is_action_pressed(“ui_right”):
velocity.x += 1.0
if Input.is_action_pressed(“ui_left”):
velocity.x -= 1.0
if Input.is_action_pressed(“ui_down”):
velocity.y += 1.0
if Input.is_action_pressed(“ui_up”):
velocity.y -= 1.0

move_and_slide(velocity * speed)
:bust_in_silhouette: Reply From: felipe_kinoshita

You could check whether the velocity is zero and then start the idle animation.