Animation not found for certain animations

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

Hello, I’ve just started working on a 2D top-down ARPG prototype, and have recently added some basic animations to test my player character. My movement and idle work, but my attack animations give me an error every frame the button is pressed:

The problem is that the way I’m setting the attack animations is similar if not the same as the movement and idle animations. I double checked the animation names too, and they match.

NOTE: facing is a variable that was inherited. It stores the ‘direction’ of movement/animation
Here is an example of my attack code:

func input_actions():
	if Input.is_action_pressed("attack_1"):
		$BaseSprite.play(wpn1_animations[facing])

Here is an example of my movement and idle code:

$BaseSprite.play(move_animations[facing])
	#Is Idle?
	if velocity == Vector2.ZERO:
		$BaseSprite.play(idle_animations[facing])

Here Is all of my code:

extends "res://ACTORS/Actor.gd"

#ACTIONS
#Basic Attacks
var attacks = ['weapon1', 'weapon2']
#Skills
var all_skills = []
var current_skills = []


#ANIMATIONS
#Idle Animations
var idle_animations = { 'right': 'idle_r', 
'left': 'idle_l',
 'down' : 'idle_d',
 'up': 'idle_u'}
#Movement Animations
var move_animations = { 'right': 'run_r', 
'left': 'run_l',
 'down' : 'run_d',
 'up': 'run_u'}

#Attack 1 Animations
var wpn1_animations = {'right': 'atk1_r', 
'left': 'atk1_l',
 'down' : 'atk1_d',
 'up': 'atk1_u'}

#AI
#AI or Not
var is_active = true

#BASE FUNCTIONS
#Weapons
# func weapon1():

#INPUT FUNCTIONS
#Input Movement
func input_movement():
	#HORIZONTAL
	if Input.is_action_pressed('move_right'):
		movement('right')
		
	elif Input.is_action_pressed('move_left'):
		movement('left')
	#VERTICAL
	if Input.is_action_pressed("move_down"):
		movement('down')
	elif Input.is_action_pressed('move_up'):
		movement('up')
	#Animations
	$BaseSprite.play(move_animations[facing])
	#Is Idle?
	if velocity == Vector2.ZERO:
		$BaseSprite.play(idle_animations[facing])


#Input Actions (Process)
func input_actions():
	if Input.is_action_pressed("attack_1"):
		$BaseSprite.play(wpn1_animations[facing])

#READY AND PROCESSES
# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.

func _physics_process(_delta):
	input_movement()
	velocity = velocity.normalized() * speed
	velocity = move_and_slide(velocity)
	velocity = Vector2.ZERO
	

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	input_actions()

#OTHER FUNCTIONS
#Returns player
func get_class(): return "Player"

Thank you in advance.

According to the posted screen shot, it seems to have successfully looked up an animation name (atk1_d). But, it’s saying that no such animation exists. Are you sure you have an animation by that name (and that it doesn’t have a character case difference or some other typo)?

jgodfrey | 2020-11-28 23:13

So I checked today, and the animations didn’t exist, but I do remember creating them and them being different. I’m going to try recreating them. Thank you!

EDIT: I have recreated the animations, but had to change when animations were played, but the animations do play now!

WinterStep | 2020-11-29 02:16