- Home /
Starting the game with specific light off
I added a torch to my game, and it's meant to do exactly what a torch does: emit light. I have it so if you have the item with the tag "Torch" and right click, the light will come on and if you click again it will come off, but my game starts with the light on. How can I set it so the light starts off?
I'm using the free version of Unity and Javascript if that matters.
Select the light in the hierarchy and click the checkmark just to the left of the word 'Light' in the inspector.
Answer by YoungDeveloper · Dec 14, 2013 at 04:58 AM
If you want all torches to be off at the start of the game, you can simply disable them in Start() function, there must be a Boolean which toggles the torch in your script.
If you want to create a possibility to choose specific torch to be off, you can create public boolean, set in game inspector, and in start function add a simple if check. Something like this.
public var enableOnStart:boolean; //Check this if you want the torch to be enabled at the start
function Start(){
if(enableOnStart) //enable torch
else //disable
}
Your answer
Follow this Question
Related Questions
photocamera flash 1 Answer
Changing a bunch of lights intensity 2 Answers
Day-night changing via rotating Directional Light 1 Answer
Light switch trigger 3 Answers
Lens-Flare Muzzleflash 0 Answers