Answer the question
In order to leave comments, you need to log in
Where is my logical error (The essence of the script is that when the Light component is turned off, the sphere should change color to white)?
using UnityEngine;
using System.Collections;
public class LightsONSctript : MonoBehaviour {
private Light myLight;
void Start () {
myLight = GetComponent<Light> ();
}
void Update () {
if (Input.GetKeyDown (KeyCode.L)) {
GetComponent<Renderer> ().material.color = Color.yellow;
myLight.enabled = !myLight.enabled;
Debug.Log("Action");
}
if (myLight.enabled = false) {
GetComponent<Renderer> ().material.color = Color.red;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question