Question by
Cooperall · Oct 05, 2018 at 02:06 AM ·
gameobjectinstantiatetransformduplicategetcomponentsinchildren
Instantiate duplicate of inactive child in GameObject
I have a GameObject, who we'll call "Guy," who is storing another GameObject inside of it as a child called "ProjCircle." Upon pressing P, I want to create a duplicate of ProjCircle at Guy's current location and then turn it active. This is my current code, but I don't know how to get from finding the Transform of ProjCircle into creating an exact duplicate of it. Any advice?
Transform[] c = gameObject.GetComponentsInChildren(true); for (int i = 0; i < c.Length; i++) { if (c [i].name == "ProjCircle") { //GameObject d = c [i]; //Instantiate (d); //d.SetActive (true); break; } }
Comment