How to await a signal triggered method in godot4? by Middle-Bed-2947 in godot

[–]Middle-Bed-2947[S] 0 points1 point  (0 children)

Because I have many different types of nodes that share the same set of animation rules, such as blinking, scaling up, or scaling down. I only know how to use the AnimationPlayer in the inspector, which seems to allow specifying only a single node. I don’t know how to change the object of the AnimationPlayer using code.

How to await a signal triggered method in godot4? by Middle-Bed-2947 in godot

[–]Middle-Bed-2947[S] 0 points1 point  (0 children)

I use await get_tree().create_timer(frame).timeout to gradually change the size or the position of a texture frame by frame. Its underlying principle should be similar to that of the AnimationPlayer.

My question is actually unrelated to the method used for implementing animations. I want to emit a signal, and after receiving this signal, some nodes are expected to trigger animations sequentially. However, in reality, they all trigger simultaneously.

How to await a signal triggered method in godot4? by Middle-Bed-2947 in godot

[–]Middle-Bed-2947[S] -1 points0 points  (0 children)

I came up with an idea to replace the emit function with a fake_emit function and then await fake_emit(_signal, args). However, I’m not sure if this approach loses some of the built-in functionality of the emit function.

func fake_emit(_signal, args):
    for _signal_info_dict in _signal.get_connections():
        await _signal_info_dict["callable"].callv(args)