Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink
Share
Go down
Member [Lv. 2]
Member [Lv. 2]
Posts : 6
Points : 941
Rep : 0
Join date : 2016-01-30
View user profile

FlashLight Script

on Sat Feb 20, 2016 6:18 pm
Assign to Empty GameObject that has a light on it

[You must be registered and logged in to see this link.]


Show Code:
function Update() {
if (Input.GetKeyDown("f")) {

    if (light.enabled == true)

        light.enabled = false;

        else

        light.enabled = true;

    }

}
avatar
Moderator
Moderator
Posts : 76
Points : 1954
Rep : 16
Join date : 2014-06-02
Age : 15
Location : Milky Way
View user profile

Re: FlashLight Script

on Wed Mar 09, 2016 7:38 pm
I think this is to much code.
You can just do light.enabled = !light.enabled;
Code:
function Update() {
if (Input.GetKeyDown("f")) {
      light.enabled = !light.enabled;
  }
}
Back to top
Permissions in this forum:
You cannot reply to topics in this forum