Quantcast
Channel: Questions in topic: "parenting"
Viewing all articles
Browse latest Browse all 302

Trying to set the parent of an instantiated object to another instantiated object

$
0
0
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?

Viewing all articles
Browse latest Browse all 302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>