0 votes

Lets say I have a function func20 that calls func19, that in turn calls func18 and so on until func1. The call stack is func20 -> func19 -> func18 -> ... -> func1. And they all use prop1:

func func_n():
    .........................
    .........................
    func_n-1()
    use_prop1()
    .........................
    .........................

Then at some point I change func_1 so it starts animation that changes prop1 and wait until the animation ends before it continues with whatever it is doing:

func func_1():
    .........................
    .........................
    start_animation()
    wait_for_animation_end()
    use_prop1()
    .........................
    .........................

How do I wait for this animation without making changes in other methods in the call stack?

Godot version 3.4
in Engine by (14 points)

1 Answer

0 votes

Could you perhaps tie your function trigger to the animation_finished signal? Then have a simple integer variable that goes up every time. This code is pretty rough but maybe it will get you close?

var _funcstate = 1
func on_animation_finished(_anim_name):
        ### INSERT FUNCTION HERE
        _funcstate = _funcstate+1
        _func(funcstate)
by (534 points)

I don't understand your proposal, can you elaborate? Which function should I insert - fun1, func2, func15? What is _func? What function trigger? And how does a simple counter help me to keep the rest of the functions - func2, func3, ..., func20 unchanged?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.