I am trying to write a script whereby when a cube lands on the floor the light turns on. I am working in C#, not in Javascript.
public class lighton : MonoBehaviour {
void OnCollisionEnter (Collision myCollision) {
Light myLight = gameObject.Find("Light").AddComponent(Light);
myLight.enabled = true;
myLight.intensity = 5;
}
}
I get an error that says:
Static member `UnityEngine.GameObject.Find(string)’ cannot be accessed with an instance reference, qualify it with a type name instead
Any input is appreciated