Execute function at specific moment

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fefinfon

I know there are questions asking for similar but I think this is more specific.

I have a player node with its own script and other node (wich is a boomerang) with its own script too. So when i press the mouse click button, the boomerang script will execute (throwing the boomerang until it comes back to its start position) and at the same time, the player script will reproduce “throw” animation.
The problem is that the boomerang will come out at time 0 of the player’s “throw” animation and I want it on 0.2
I know that there’s method calls for animations, but I don’t know how to apply them on this certain case where are two different scripts for each node.

Maybe using a timer is right what i want, but I’m not sure.

Other thing I want to do is that player can’t execute “throw” animation if boomerang is flying

Thanks in advance.

:bust_in_silhouette: Reply From: exuin

In the player’s throw animation, after 0.2 seconds call the function that moves the boomerang. AnimationPlayers can work on multiple nodes at once.

Thank you! That worked to match the animation!
Now, do you have any idea of how can I make that player can’t execute “throw” animation and make the boomerang can’t launch if the boomerang is flying? (so as not have more than one boomerang in air)

fefinfon | 2021-06-02 07:50

You can set a boolean value on the player. When the player tries to throw a boomerang, if can_throw is true, start the animation and set it to false. Else, don’t. And when the boomerang returns you should set it to true.

exuin | 2021-06-02 16:47

Hi! thanks for your answer! I think I’ve already done that, but I’m not sure if It’s ok…
Maybe some images will help to better show what I’ve done

Boomerang script

Player script


fefinfon | 2021-06-03 00:10