I have a Unity project in which the door is set to the GameObject "Door". It is fine and set in the editor (i.e. when I'm not playing it), but as soon as I hit play, it turns to "None (GameObject)". My script uses the Rigidbody component of the door, but I access that through the script. Do I need to reference the Rigidbody component instead?
Why is it doing this?
using UnityEngine;
public class GameManager : MonoBehaviour {
public GameObject door;
void Start ()
{
door = GameObject.Find("Door1");
}
public void NextLevel () {
Debug.Log("open");
door.GetComponent<Rigidbody>().AddForce(0, 0, 500);
}
}