0 votes

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.

Godot version 3.4
in Engine by (21 points)
edited by

1 Answer

0 votes

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...

by (12,475 points)

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

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.