0 votes

So I want to make a FNAF fan game where turning off the power is a mechanic and it's supposed to be done with a switch. However I can't figure out how to make it work. I can't show the code for the switch as I am not at my PC right now but I have gotten frustrated with trying to figure it out so I will do the second best thing to explain how it works in engine. So the Light-switch sprite is a textured button node that when pressed will make a darkened overlay visible indicating that the power is off. However once the power is off, it seems like you can't click on it again. I have tried different signals, messed around with the settings of the textured button mode but it still didn't work after one click or you can click it over and over again and have it do absolutely nothing. I don't know what to do at this point. Should I make it a Kinematic Body instead or am I missing something?

Godot version 3.4
in Engine by (39 points)

1 Answer

+1 vote
Best answer

Hello. Bear with me, I'm guessing at your question.

I think you are saying you made a Button with Toggle Mode on. This allows you to click it once for down, click again for up, a bit like a light switch. You need to connect some code to the toggled() signal, instead of the usual pressed signal. The function you connect to will take a parameter, sort of like:

func on_Lightswitch_toggled(is_on: bool):
     if is_on:
           DarkenedOverlay.hide()   # Lights are on, easy to see
     else:
           DarkenedOverlay.show()  # No lights, look through the shadows

I hope this help. If it does, reply and let me know. Otherwise, please add some code to your question.

by (335 points)
selected by

Thank you so much! I tried.it out and it worked perfectly!

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 Frequently asked questions and 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 [email protected] with your username.