Error : Unknown identifier : FlashLight
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.
Answer by Shadowskull1247 · Jun 27, 2017 at 04:38 AM
Add var Flashlight: GameObject;
at the top of the second script and attach the actual light source in the inspector to it and it should work. If you have any other issues, let me know.
Your answer
Follow this Question
Related Questions
Carrying an object using Javascript 0 Answers
How do I make a working flashlight with batteries? 0 Answers
Pickup Script Problem 1 Answer
Script error to pick-up flashlight 5 Answers
Help with UFPS and Flashlight/Lantern & Battery system. 0 Answers