Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 /
This question was closed Mar 06 at 03:34 AM by morgansmith20904 for the following reason:

I made a mistake, i had a bit of code that i didn't know about and it ruined everything.

avatar image
0
Question by morgansmith20904 · Mar 04 at 05:38 PM · parent-childparent transform

Changing the parent of an object gets rid of its parents?

So i have 3 objects, A,B, and C. A is the parent of B, and i want to set C's parent to be B. But when i use SetParent, C.transform.parent = B.transform, or instatiate C with B as the parent, in every case B stops being a child of A. I know i can just run more code every time to set A as the parent of B, but it feels like there should be a better way of doing it then that.

A and B are a part of the same Prefab and C is a seperate one. i dont know if this changes anything, but it might be relevant. Any Ideas?

EDIT; It turns out i am an idiot and forgot about this horrible bit of code i hid in C. transform.parent.parent = A; I removed this and all my problems were solved. Instantiating works, changing C's parent to B works, all of it. i just was dumb.

Comment
Add comment · Show 2
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 sacredgeometry · Mar 05 at 11:59 AM 0
Share

What code are you writing and which version of unity are you using. Because on paper there is nothing wrong with what you are doing.

avatar image morgansmith20904 sacredgeometry · Mar 05 at 04:53 PM 0
Share

i have tried

Instantiate(C,B); C.transform.parent = B.transform; C.transform.setParent(B.transform);

and all of them force B to be parentless. i have no other code anywhere in any scripts that even references B or C.

i am currently on the beta 2022.1.07b

1 Reply

  • Sort: 
avatar image
0

Answer by keroltarr · Mar 05 at 08:26 PM

This may be due to the use of prefabs.

Make sure A. is instantiated (or already in the hierarchy).

Also make sure that the A that is the parent of B is the one in the hierarchy (not a prefab)

Comment
Add comment · Show 2 · 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 morgansmith20904 · Mar 06 at 03:07 AM 1
Share

Thank you, your suggestion didn't work, but because of it i better checked all my scripts again and found the accursed line ruining everything.

avatar image keroltarr morgansmith20904 · Mar 06 at 11:44 AM 0
Share

great, sometimes that's what it takes

Follow this Question

Answers Answers and Comments

133 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SetParent does not work. 1 Answer

Can child game object with OnTriggerEnter function use parent game object's collider? 2 Answers

Make child's transform independent of parent 1 Answer

GameObject won't move after got child 1 Answer

Extremely confused with parent and child object system 1 Answer


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