Hi im trying to set a Gameobject variable in a script not in the inspector.

public GameObject planet;

    void Start () {
         planet = GameObject.Find("Planet");  
	}

I tried a few different things but in the inspector the game object is still blank when i try to test it. I would prefer not to use prefabs if possible.

Are you sure that the GameObject called “Planet” exist in your current scene? If it is a prefab that is not in the scene you can’t decleare it so.

[SerializeField]
private GameObject Planets;

        void Update() 
        {
        Planets = GameObject.FindGameObjectsWithTag("Planet");
        }

I hope this helps :smiley:

@Spardom
You could try this. Hope it works cheers.

public GameObject planet;
    void Start() {
        if (planet == null) {
            planet = GameObject.FindGameObjectWithTag(“planet”);
        }
    }