Godot-未找到动画

发布于 2025-02-08 05:16:27 字数 3257 浏览 1 评论 0原文

我从动画开始, 我的角色具有右,左上和向上的动画动画 上传时,角色可以正确执行动画,但是在控制台上,我会遇到一个错误:“ play:and and andion n of Anivation:run_up” 错误:“播放:找不到动画:IDLE_UP”,

当我上升时,错误开始出现。 当我去其他任何地方

错误log

错误详细信息

场景

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"

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

Error log

Error detail

Animations list

Scene

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2025-02-15 05:16:27

我能够解决错误
显然,现场外面还有另一个角色引起冲突,因为他还有其他类型的动画
我删除了那个角色,并解决了

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文