Godot Version
4.5.1
Question
Hi, i’m new to coding, my AnimatedSprite2d is not playing when i enter the game. It works when I hit autoplay in the node but the other animations are not playing when i’m moving in game. this is the script I used
extends CharacterBody2D
const SPEED = 100.0
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
func _physics_process(delta: float) → void:
process_movement()
move_and_slide()
func process_movement() → void:
var direction := Input.get_vector(“left”, “right”, “up”, “down”)
velocity = direction * SPEED
func play_animation(dir: Vector2):
if dir.x > 0:
animated_sprite_2d.play(“walk_left”)
elif dir.x < 0:
animated_sprite_2d.play(“walk_right”)
elif dir.y > 0:
animated_sprite_2d.play(“idle_down”)
elif dir.y < 0:
animated_sprite_2d.play(“idle_up”)