#why wont this change to the idle when not moving

3 messages · Page 1 of 1 (latest)

versed flame
#

extends CharacterBody2D

const SPEED = 500.0
const ACCEL = 2.0

var input: Vector2
var direction = 0

func get_input():
input.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
return input.normalized()

func _process(delta: float) -> void:
var playerInput = get_input()

velocity = lerp(velocity, playerInput * SPEED, delta * ACCEL)

move_and_slide()
if not velocity.is_equal_approx(Vector2.ZERO):
if input.y > 0:
direction = 0

if input.x > 0:
direction = 3

if input.x < 0:
direction = 2

if input.y < 0:
direction = 1
if velocity.is_equal_approx(Vector2.ZERO):
match direction:
0:
$AnimatedSprite2D.play("idle_front")
1:
$AnimatedSprite2D.play("idle_back")
2:
$AnimatedSprite2D.flip_h = true
$AnimatedSprite2D.play("idle_side")
3:
$AnimatedSprite2D.flip_h = false
$AnimatedSprite2D.play("idle_side")
else:
match direction:
0:
$AnimatedSprite2D.play("walk_front")
1:
$AnimatedSprite2D.play("walk_back")
2:
$AnimatedSprite2D.flip_h = true
$AnimatedSprite2D.play("walk_side")
3:
$AnimatedSprite2D.flip_h = false
$AnimatedSprite2D.play("walk_side")

it just wont work

stray orbit