I am trying to have one gameobject set active upon another gameobject moving beyond its current position in the y axis. Please help if you can. Getting a “Missing Field Exception: System.Boolean.transform” error. Whatever that means. See code below. Please help. Thanks.
function Update (){
if ((gameObject.tag == “door”).transform.position.y > 1){
doorlight.SetActive(true);
}
}
public class YourClass : MonoBehaviour
{
public GameObject doorlight; // drag&drop this in inspector
private GameObject door; // we will find this (or could make it public and also drag&drop in inspector, then Start() isn't needed)
function Start()
{
door = GameObject.FindWithTag("door"); // find the door - game object with door tag
}
function Update()
{
if (door.transform.position.y > 1)
{
doorlight.SetActive(true);
}
}
}
Question is, how you actually want to define, initialize and access your door. You gave very little detail about your game and what door or light are and how you access them.