- Home /
Moving gameobject to Sibling's child ("Niece?").,Moving Gameobject into sibling's child ("Cousin?") c#
Basically, I want to move "Arcane Circle" into "Controller (left)" OnTriggerEnter, preferably in c#. I feel like I've tried everything at this point, and nothing has worked. I've milked Google dry and I would really appreciate it if someone would tell me the answer to this. Thanks in advance.
,Basically, I want to move the "Arcane Circle" into "Controller (left)" OnTriggerEnter, preferably with c#. I feel like I've tried everything, and I've run out of leads on Google. If someone knows the answer, please do tell and thanks in advance.
Answer by b1gry4n · May 31, 2018 at 12:42 AM
theres quite a few ways to do this. transform.GetChild(0) will return the first child of the transform. you could use this if your gameobjects will always have the same order.
Transform ControllerLeft = Important.GetChild(0).GetChild(0);
arcaneCircle.parent = ControllerLeft;
or if youre able to just have references to the controllers...
public Transform controllerLeft;
public Transform arcaneCircle;
void SomeFunction()
{
arcaneCircle.parent = controllerLeft;
}
if youre trying to do this without having a reference from gamestart theres a few ways. the easiest is to have a unique script on the controller left/right
UniqueScript[] controllers = Important.GetComponentsInChildren<UniqueScript>();
foreach (UniqueScript unique in controllers)
{
if (unique.leftEye)
{
ArcaneCircle.transform.parent = unique.transform;
break;
}
}
I guess it was so simple, that no site I found with what I was searching had the explanation. Thank you so much :D
Your answer
![](https://koobas.hobune.stream/wayback/20220612163737im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
An OS design issue: File types associated with their appropriate programs 1 Answer
Is it possible to reparent an object to the root of a scene? 2 Answers
How to Select objects and move and rotate them on the x,y,z axis. 2 Answers