Hello, I recently created a life script of the battery of my lamp. Here it is :
#pragma strict
var flashLight : Light;
function Start ()
{
flashLight.GetComponent.<Light>().enabled = false;
flashLight.GetComponent.<Light>().intensity = 8;
}
function Update ()
{
if(flashLight.GetComponent.<Light>().enabled == true)
{
flashLight.GetComponent.<Light>().intensity -= 0.1 * Time.deltaTime / 5;
Debug.Log(flashLight.GetComponent.<Light>().intensity);
}
}
I then downloaded a script on the Internet that allows to collect batteries, but I can not start the game because of the error: Unknown identify FlashLight.
var buttonInRange;
var buttonActivated;
var batterySound : AudioClip;
private static var batteryPower : float = 10;
public var guiSkin : GUISkin;
private var hasPlayed = false;
function OnTriggerEnter (c : Collider)
{
buttonInRange = true;
}
function OnTriggerExit (c : Collider)
{
buttonInRange = false;
}
function OnGUI ()
{
if(buttonInRange == true)
{
GUI.skin = guiSkin;
GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Pick up batteries");
}
}
function Update ()
{
if (buttonInRange == true)
{
if (Input.GetKeyDown ("e"))
{
if(!hasPlayed)
{
AudioSource.PlayClipAtPoint(batterySound, transform.position);
Flashlight.AlterEnergy(batteryPower);
Destroy(gameObject);
hasPlayed = true;
}
}
}
}
I think we should add a variable but I do not know which.
Thank you.