Prevent input processing during animation

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

Hello!

I have a menu with buttons and once a button is clicked, I created an helper that attach a node instance to the scene that play a fade in animation.
This is working properly (even if I don’t know if this the most optimised way to do this).
When the animation ends, I change the scene.

My problem is when the animation is playing I would like to prevent to launch the button’s function again. At the moment I’m using:

get_tree().get_root().set_disable_input(true)

but the next scene won’t be able to process inputs, so I enable the input in the ready function. But… I don’t think it’s an elegant way to do this.

Is it safe to enable the inputs right after I call the change_scene() function?
Especially if I press enter a lot of times.

EDIT: My game is designed to be played on keyboard and gamepad only.

I would like to avoid to add issue in my game.

Thank you for your help.

:bust_in_silhouette: Reply From: jgodfrey

One solution would be to add an invisible “overlay” on top of the buttons that would stop the mouse clicks from getting to the underlying buttons.

For example, if you add a screen-sized TextureRect (transparent or translucent as you need) lower in the scene tree than your buttons, it will preven the buttons from being pressed…

Perhaps that could be an addition to your existing “fade” scene…

Thank you for your answer! It would be a solution indeed, but my game is designed to be played on keyboard and gamepad only.

Cronos87 | 2022-05-11 15:52