• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TheEmeralDreamer · Sep 17, 2011 at 08:15 PM · parentchild

Finding the origin of child's parent

Is there some way I can find the root parent(if a child has multiple parents) of an object that is parented to, say a bone? It would be much more simple for me to place this "root" in a variable and reference it than have to write specific 'transform.parent.parent.parent'etc.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Sep 17, 2011 at 08:43 PM

"Multiple parents" is not possible. I guess you mean when the child is quite deep nested.

The Transform class has a shortcut for this:

 transform.root

root-documentation

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheEmeralDreamer · Sep 17, 2011 at 08:48 PM 0
Share

I said transform.parent.parent does find the object that is parented two levels above the object you are referencing from. If an object is parented to something that has been parented, it is parented more than once is it not?

which is why transform.parent.parent even works. But you answered my question, thanks for the shortcut.

avatar image Bunny83 · Sep 17, 2011 at 11:18 PM 0
Share

There's a huge difference between a parent and a grandparent. A Transform component can only have one parent. It's a tree-structure, not a graph-structure.

Even in the "real" world the parents of your parents are not your parents, because you only have one (pair).

avatar image TheEmeralDreamer · Sep 17, 2011 at 11:22 PM 0
Share

regardless. the code works like stated, which means unity recognizes multiple tiers of parents

avatar image TheEmeralDreamer · Sep 17, 2011 at 11:29 PM 0
Share

Also Grandparent houses the word parent. Which means it's still a parent. There isn't a huge difference. It just means the parent of your parent.. which is still more than one parent and either way is "multiple" parents.

avatar image Bunny83 · Sep 18, 2011 at 12:47 AM 0
Share

:D well, i don't want to start a flame-war but especially in computer science it's important to use the right terms since there's not much room for interpretation. The parent is always the direct ancestor and in a tree structure a child can only have one parent.

Btw. a computer-mouse isn't a computer neither an animal just because it houses the two words. But you're right a grandparent is still a parent, but not your parent.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Make a simple tree 1 Answer

How to detect child object collisions on parent 3 Answers

Instantiating as a child error 1 Answer

How do I allocate a parent to a gameobject that just got instantiated? 2 Answers

Rotate children around parent pivot 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges