How do I make one object a child of another in JavaScript?
And, how do I then un-child an object in JavaScript?
How do I make one object a child of another in JavaScript?
And, how do I then un-child an object in JavaScript?
myobject.transform.parent = otherobject.transform;
myobject.transform.parent = null;
hopes he got his JS syntax right
-Jon
Ohh, in the object’s Transform properties.
Now, why didn’t I look there?
Thanks!
Yeah, I think it makes sense there when you think about it. I don’t think they can just have the parent aliased so you could also do myGameObject.parent , because that’d assume every game object has a Transform component… which isn’t totally the case.
hmm
-Jon
Yeah, it seems logical enough. After all, translating, rotating and scaling are the only things you do with whole hierarchies. I just never thought of that until now.
I wonder though, is there some non-transform-related thing we might want to do to a group of objects based on their hierarchical relationship?
Hmm …