Hi guys,
sorry to bother. I really hope this is not too stupid, but I don’t manage to get it right.
So, what I want to do:
if [Event] change the intensity of a point light from 0.01 to 1.5 over x seconds under a certain condition.
My Code:
public class LightWall : MonoBehaviour {
// public float timer = 10.0f;
public Light lt;
// Use this for initialization
void Start ()
{
lt = GetComponent<Light>();
}
// Update is called once per frame
void Update ()
{
// FIRST METHOD THAT DID NOT WORK
// timer -= Time.deltaTime;
// if (timer <= 0)
// LightIntensity ();
// ANOTHER TRY VIA PUBLIC STATIC BOOL
// if (outer_fadein.fadeBegin == true)
LightIntensity ();
}
void LightIntensity ()
{
lt.intensity = Mathf.Lerp (0.01f , 1.5f , Time.time/5);
Debug.Log ("LightIntensity =" + lt.intensity + Time.time);
}
}
The Problem:
If I simply call the function in Update, it will increase the light perfectly fine from 0.01 to 1.5. But I only want this to happen after 10 seconds, or better, after fadebegin is set to true. When I try it with one of the two conditions, the light intensity apruptly strikes in instead of beginning at 0.01.
Don’t know if it’s valuable info, but: outer_fadein.fadeBegin will be set to true after 10.00 seconds.
Thanks for the help, I really appreciate!
Cheers!
EDIT:
I think the problem is Time.time in
lt.intensity = Mathf.Lerp (0.01f , 1.5f , Time.time/5);
Since Time.time (which is in my understanding global time since app started) is not 0 when fadeBegin is set to true, intensity will not begin at 0.01f, correct?
How do I solve this? I definetly want this fade to be controlled over a time based value and not being dependant on framerates.