Before I posted here I did a search and found tons of solutions to this, but nothing is working and I am getting an error. I added a spot light as a child object to the FPS Controller, the default one provided. I have programming experience in Objective C and C. but here is the FULL code so far.
using UnityEngine;
using System.Collections;
public class lightOnOff : MonoBehaviour {
var linkedLight : Light; // Light has a red line???
void Start () {
}
void Update () {
if(Input.GetKeyDown("f")){
linkedLight.enabled = !linkedLight.enabled;
}
}
}
On line 5 I am getting a red underline on the word ‘Light’. Why? What am I missing?
Earlier I tried it out myself and use ‘public Gameobject flashlight;’ I then dragged a Spot Light I was using as the flashlight to this script to link it to script. But I was unable to use methods like ‘flashlight.enable’. The way I tried it must be wrong but it seem logical that it should be able to function like that. any help would be nice ![]()