0 votes

Hi all,

I have a condition, that when it reaches 7 it kicks in, as shown below:

elif failedAttempt == 7 and not progression:
    playSound("neckSnap")
    get_node("man/head/torso/hips/leg_l").show()
    get_node("man/AnimationPlayer").play("fall")
    globals.hung = true             #we is dead.  So we can process death stuff in messages to player

    #play a timer so that we can hear the sounds, watch the animation, etc.  THEN move to next scene
    timer.set_one_shot(true)
    timer.set_wait_time(0.6)
    timer.connect("timeout", self, "_on_Timer_timeout")
    timer.start()
    print("timer did that thing")
    _on_Timer_timeout() #go to finish screen

The function _on_Timer_timeout() loads up the next scene, which stops anything in this scene. What I'm trying to do, as you can see, is play the sound neckSnap and an animation called fall before heading off to the next scene.

I don't know what's wrong with my timer, primarily because I'm not very good at all of this as yet. Can anyone see anything glaringly obvious as to why it's jumping straight to the next scene via _on_Timer_timeout() rather than playing the sound and animation?

Thanks a tonne... Rob

in Engine by (825 points)

1 Answer

+2 votes
Best answer

Probably, your sound and animation durations are longer than timer waiting time.
I suggest to use a Call function track keyframe at the end of animation that calls changing scene.

-j

by (1,469 points)
selected by

Thank you that does sound like a great idea.

I just had a go though and when I create a new function track, a dialog appears and asks me "Call functions in which node?"

The problem is it's only showing me nodes in the current scene but I want to call a function in another scene. Is there a way to do that?

EDIT: I ended up just moving the function to the local scene but if you do know it would be interesting as I'm sure this will come up. Thanks again for the help.

If your function is critical you can declare it in a singleton script (for example globals.gd) and then call it from any other scene with:

get_node("/root/globals").yourFunctionName()

Regards
-j

Finally figured out the singleton concept. Really useful thank you.

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 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 webmaster@godotengine.org with your username.