I know how crazy this sounds, but is it even possible? I have a instantiated object called wordClone which I want to set parent to another instantiated object called wordObj. To explain further I will include my code:
enemyClone = Instantiate(enemyPrefab, screenPosition, Quaternion.identity);
enemyClone.transform.SetParent(GameObject.Find("WordManager").GetComponent().wordObj.transform);
So for this to work, wordObj which is in the WordSpawner script must be public, but then Unity expects me to create a reference to it in the inspector as it is public, which I can't do as it doesn't exist yet. While this still compiles, it doesn't create the parent since there is no reference. Any ideas how I could do this, perhaps without making wordObj public?
↧