- Home /
Does a child transform take the name of its parent in unity 3D?
I have a transform that is the child of another transform in unity 3D. Attached to the child transform is a script. When I try accessing the name of the child transform within this script (by using this.transform.name) I get the name of the parent transform. Is there any way I can get the name of the child transform instead?
Thanks
Answer by MakeCodeNow · May 24, 2014 at 05:45 PM
In Unity every node has its own name. This can be the same as other nodes or different. It's just a string. If your script is on the child, then this.transform.name is the same as this.name, and both should return the name of the child. this.transform.parent.name would return the name of the parent. If you are getting the parent name in the child, probably your script is not doing what you think it is.