Reputation: 1
I'm starting with the animations, I have a character with movement animations for right, left and up When uploading, the character performs the animation correctly, but on the console I get an error: "play: Animation not found: Run_Up" error :"play: Animation not found: Idle_Up"
the error starts to come out, when I'm going up. it stops when i go anywhere else
extends KinematicBody2D
var VELOCIDAD_MAXIMA = 100
var ACELERACION = 350
var FRICCION = 850
enum {
RUN,
PUSH
}
onready var animation_player = $AnimationPlayer
export var velocidad = Vector2.ZERO#(0, 0)
export var direccion_vector = Vector2.DOWN#(0, 1)
export var direccion = Vector2.ZERO#(0, 0)
export var push_finished = false
var estado = RUN
var targets = []
func run_state(delta):
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
direccion_vector = input_vector
velocidad = velocidad.move_toward(input_vector * VELOCIDAD_MAXIMA, ACELERACION * delta)
_play_animation("Run")
#Si el usuario no esta tocando al personaje
elif velocidad.length() == 0 && Input.is_action_pressed("action"):
_play_animation("Push")
if $RayCast2D.is_colliding():
push_finished = false
estado = PUSH
else:
velocidad = velocidad.move_toward(input_vector * VELOCIDAD_MAXIMA, FRICCION * delta)
_play_animation("Idle")
velocidad = move_and_slide(velocidad)
func push_state(_delta):
var collider = $RayCast2D.get_collider()
collider._on_interact($RayCast2D.rotation_degrees)
if collider:
estado = RUN
velocidad = move_and_slide(velocidad)
func animation_finished():
if !Input.is_action_pressed("action"):
estado = RUN
velocidad = Vector2.ZERO
func _physics_process(delta):
match estado:
RUN:
run_state(delta)
PUSH:
push_state(delta)
func _play_animation(animation_type: String) -> void:
var animation_name = animation_type + "_" + _get_direction_string(direccion_vector.angle())
if animation_name != animation_player.current_animation:
animation_player.stop(true)
animation_player.play(animation_name)
func _get_direction_string(angle: float) -> String:
var angle_deg = round(rad2deg(angle))
#glanced up
if angle_deg == -90:
$RayCast2D.rotation_degrees = 180
return "Up"
#glanced down
if angle_deg == 90:
$RayCast2D.rotation_degrees = 0
return "Right"
#glanced left
if angle_deg == 180:
$RayCast2D.rotation_degrees = 90
return "Left"
#glanced right
if angle_deg == 0:
$RayCast2D.rotation_degrees = -90
return "Right"
return "Right"
Upvotes: 0
Views: 973
Reputation: 1
I was able to fix the error apparently there was another character outside the scene that was causing conflict, since he had other types of animations I deleted that character and it was solved
Upvotes: 0