stop a function from running

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

i have the function that makes the enemy move and i have another function that makes the player able to kill the enemy . when the second function is running the enemy will still move 1 sec before he dissepears so i want to stop the first function :slight_smile:

this is a duplicate post of a post that you made a minute before this post. Probably best to only have one post for a single question

godot_dev_ | 2023-06-14 13:33

how does the enemy move, perhaps in _process? You could disable processing by set_process(false) (doc). You could also hide the node or just move it somewhere else.

spaceyjase | 2023-06-14 16:21

:bust_in_silhouette: Reply From: GameSchool


With the provided info it’s a really hard question. But, if you’re using _process or _physics_process, you can disable it with set_process(false) or set_physics_process(false)

If you’re not using this functions and have a custom function instead, you can add a global variable in the script that will be a true or false (A bool variable) and use the move function only if it’s true and change it to false when the enemy takes damage.

I can’t give you a real solution for your case without having the actual code, but maybe one of this solutions will help