Hi guys,
I’m new in unity and scripting and I need your help for my project.
I have a Point light attached to my player and I added a script to it, for decrease the Light Range through time. here my script:
var lerpTime : float;
var maxRange : float; // I put it to 10 in game
private var i : float = 0;
var GameScene : String;
function Update ()
{
light.range = Mathf.Lerp(maxRange,0, i/lerpTime);
i+= Time.deltaTime;
if(light.range <= 1) // GameOver scene
{
Application.LoadLevel(GameScene);
}
}
Also the player needs to find something to increase the Range and I attached it to my Player:
function OnTriggerEnter (objetInfo:Collider)
{
if(objetInfo.gameObject.tag == "Power") // Name of the tag of object
{
Destroy(objetInfo.gameObject);
}
}
And in the end, I attached to the same Point light, the script bellow to reset the Range of my light:
function OnTriggerEnter (objetInfo:Collider)
{
if(objetInfo.gameObject.tag == "Power")
{
light.range = 10;
}
}
VOILA
When I play, Light range decrease through time but it never reset when I pick the object …
any help will be wonderful