- Home /
Question by
BokuDev · Jul 24, 2015 at 07:19 PM ·
lightingscriptingbasics
Make my FlashLight start off instead on.
This is my headlamp script. Though my script only allows the headlamp to be ON at the very start and toggled off but I want it to be off at the start so it has to be turned on, and not already on; here is my script please help:
using UnityEngine;
public class HeadLight : MonoBehaviour
{
public Light FlashLightObject;
private bool LightEnabled = false;
void Update ()
{
if(Input.GetButtonDown("HeadLight"))
{
LightEnabled = !LightEnabled;
FlashLightObject.enabled = LightEnabled;
}
}
}
Comment
Answer by supernat · Jul 24, 2015 at 07:22 PM
You can turn the light off in the Awake method:
void Awake() {
FlashLightObject.enabled = false;
}
Your answer
Follow this Question
Related Questions
Lightning fade in, and then fade out. 0 Answers
help on 2d platform movement 1 Answer
Sketchup models very dull 0 Answers
How can i make level lock and unlock System 1 Answer
Is it possible (how?) to hide a light effect with a 2D sprite? 0 Answers