Why can't I add a light to a script?
I'm new to C# and I'm not very good at it, I'm currently trying to make a light that brightens up, here's the code using UnityEngine; using System.Collections;
public class LightTestScript : MonoBehaviour {
public Light LightPoint;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
LightPoint.intensity = Mathf.Lerp(LightPoint.intensity, 100f, Time.deltaTime);
}
}
I don't know if anything is wrong with it, I've tried dragging and dropping the light into the Light section but to no avail.
Answer by Mmmpies · May 27, 2016 at 05:49 PM
Light intensity only goes up to 8 anyway so 100 will instantly increase it to max. Also your doing = each time not +=. Really though just try something far more simple like this...
LightPoint.intensity += 0.3f * Time.deltaTime;
EDIT - By the way your script works, the only thing I changed to get it working in a noticeable way was delete the directional light from the test scene I created and that one line. Dragged the script on the point light and the point light onto the public slot in the inspector, worked first time.
Your answer
Follow this Question
Related Questions
Weird graphic bug 0 Answers
I have light problem in Unity 5.4.1f. Please help. 0 Answers
Unity 2D - Material for light 2 Answers
Overexposed textures on Unity 5.3 0 Answers
Google Cardboard for Unity renders only one light source 1 Answer