Light switch

Wout Hiemstra 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 9

So iam trying to make a Flashlight it has a spot light in it but now i want it to go on and off how would i dot that? Something like if F is pressed Spotlight goes on or off

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Pretty simple. You could do it all under one GameObject on the light like such:

You could also keep input completely separate, by calling it in a seperate object like this. 

then the event on the light itself would be this:

*Edit: you could also just SetActive the light gameobject instead, if you have no other scripts on it.

Thanks man that really helped!

So i cant seem to find the get key down event any idea how i can get it?

Just  type input in the finder.

Well i did that all i have is Keyboard input Mouse input or Button input

You can use the On Keyboard Input. Just select it Those options are from going to events/input, but if you type input you will get many more.

Ah didn't even think of that. I use rewired, don't get an event option.


All good. Best to assume people are not using additional assets or mention you are using them when creating the macros. In any event, keep it up, very good work.


If you're missing get key down, it might be related to the missing assemblies in Unity 2017.2 + which hasn't been officially fixed in the live version yet, see: http://support.ludiq.io/forums/5-bolt/topics/386-missing-units-in-unity-20172/

Otherwise yes, this is the proper way of doing a light switch!