#Instancing animation with get_animation_list() - AnimationPlayer

13 messages · Page 1 of 1 (latest)

fluid hollow
#

Godot 4.2.2 *ps i have asked this on godot forumn but no replied yet so i decided to ask here
Hello everyone,
I’m having trouble with instancing my jump_effects(). I’ve been trying to debug it for hours and HOURS but I couldn’t find a solution, well i have asked something regarding this issue but i have fixed the error now comes the new issue. I have a scene that manages jump effects,
This scene contains an AnimationPlayer node with various animations, such as “landing” and “double”. I use get_animation_list() to fetch the list of animations
for testing purposes to check if its EVEN instancing I created a landeffect() function and it worked so its got nothing to do with position or my code with instancing. However the jump_effects() function does not instance anything or play the animations as expected when I get the string name e.g “landing” which is the same as my animation player animation name. it never throws an error or anything and despite being called and printing debug messages, it does not instance the effect or play the animations.

I have a Scene that manages jump effects here’s an example.

@onready var animation_list: PackedStringArray = animation_player.get_animation_list()
var current_animation: String = "landing"


func _physics_process(_delta):
    if current_animation in animation_list:
        animation_player.play(current_animation)
    


func _on_landing_effect_animation_finished():
    self.queue_free()


func _on_double_effect_animation_finished():
    self.queue_free()`
Here however is when I call the functions.```
#
    jump_effects() # this one doesnt work when i try to instance 
    landeffect() #this one works if i create a instance like normally
func jump_effects():
    if jump_vfx: #jump_vfx is a preloaded scene that contains an AnimationPlayer node with different types of animations. like this 
        var jump_instance = jump_vfx.instantiate()
        if physics.velocity.x == 0:
            jump_instance.current_animation = "double"
            print("i am called but i dont work")
        else:
            jump_instance.current_animation = "landing"
            print("i am called but i dont work too")
        
        jump_instance.global_position = %landeffect.global_position
        print("position", jump_instance.global_position)
        get_tree().root.add_child(jump_instance)

func landeffect():
    if landing_effect:
        var landing_instance = landing_effect.instantiate()
        landing_instance.global_position = %landeffect.global_position
        get_tree().root.add_child(landing_instance)```
        
        
issue:
The jump_effects() function is called, and the debug messages are printed
but the instance does not appear in the scene, and the animations do not play.

what I tried:
Verified that jump_vfx is correctly preloaded and confirmed that the function is being called and the correct animation name is set.

Any help or suggestion would be much appreciated
Many thanks, FlameBamboo
robust oasis
fluid hollow
#

not working

#

😭

robust oasis
#

This seems like a very weird setup to me. Do you get any warnings in the debugger when running this?

fluid hollow
#

uh i might do something else

#

okay i tried different approach but still this fkin get_animation_list() is not working

#

i gave up

#

im gonna just have to preload each effects

analog cipher
#

I agree that the setup is a little strange seemengly instancing animation states, not sure if i can help with that but maybe for the animationlist have you tried animation_player.sprite_frames.get_animation_list()

fluid hollow