Hello people. I have 2 variables in my Flashlight script (which is located on a spotlight on the maincamera): batteryLife and maxBatteryLife. I wanted a reload type of thingy because the flashlight shuts off when batteryLife <= 0.
So i made a new script (located on the first person controller) and tried calling the two variables from Flashlight, but i get this Error: NullReferenceException: Object Reference not set to an instance of an object PickUpBatteries.ReloadCamera()
#pragma strict
function Update ()
{
if (Input.GetKeyDown("r"))
{
ReloadCamera();
}
}
function ReloadCamera ()
{
GetComponent(Flashlight).batteryLife = GetComponent(Flashlight).maxBatteryLife;
}
Can you guys help me tweak it and thell me what im doing wrong?