I have something set up where a statue’s eyes follow the player as they move, and a spotlight that originates from the eyes does the same thing. When the player clicks on the eyes, they change color. But I also want the spotlights color to change as well, but I can’t seem to get it working. The spotlight is a child on the eye, if thats important to know. Here’s my code:
using UnityEngine;
using System.Collections;
public class EyeColor : MonoBehaviour {
public static Color myColor;
public static Color spotcolor;
public Light targetlight;
void Start() {
targetlight = GetComponent<Light> ();
}
void OnMouseDown(){
if (myColor == Color.yellow){
myColor = Color.red;
} else if (myColor == Color.red){
myColor = Color.black;
} else {
myColor = Color.yellow;
}
transform.GetComponent<Renderer>().material.color = myColor;
targetlight.color = myColor;
}
}
Can anyone give me any tips?