Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Apr 01, 2017 at 03:30 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
6
Question by Cyrille-Paulhiac · Jul 24, 2011 at 03:14 PM · transformscaleparentheritage

How to avoid scaling heritage when parenting.

Hello everyone. Have you ever tried to parent a gameObject un under a scaled father ? The scaling in herited, and your GameObject is scaled with weird scaling parameters. But how setup a child under a scaled parent without impacting the scale ? Try this context:

     GameObject myCubeAsParent = GameObject.CreatePrimitive(PrimitiveType.Cube);
     myCubeAsParent.transform.Translate(1,2,3);
     myCubeAsParent.transform.Rotate(25,45,65);
     myCubeAsParent.transform.localScale = new Vector3(2,0.5f,5);
     
     GameObject mySphereAsChild = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     mySphereAsChild.transform.position = myCubeAsParent.transform.position;
     
     mySphereAsChild.transform.parent = myCubeAsParent.transform;
     

As a start, I found that: Instead of parenting, let's match the roation of the parent first:

 mySphereAsChild.transform.rotation = myCubeAsParent.transform.rotation;
 mySphereAsChild.transform.parent = myCubeAsParent.transform;

It works ! Now The scale is preserved, but the gameboject is rotated as the parent, so now I need to reset the rotation to (By rotating in UI, I found these empiric values : (350,25,300) ) Anyone have some clues to findout how to restore/preset basic transform values while parenting ?

Comment
Comments Locked · Show 1
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 Swiss Miss · Feb 06, 2015 at 11:31 PM 0
Share

This worked for me. Clever! Thank you.

3 Replies

  • Sort: 
avatar image
4
Best Answer

Answer by sneftel · Jul 24, 2011 at 03:58 PM

It's not clear what elements of the parent's transform you want inherited by the child, and what elements you don't, so I can't give you a very exact answer. I will tell you, though, that parenting an object to a parent with a non-uniform scale will generally give you results that you weren't expecting. If you want to scale the parent mesh, it's a better idea to make the two meshes siblings, and put the scale in the mesh node instead of the (new) parent node.

Comment
Comments Locked · Show 3 · 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 Cyrille-Paulhiac · Jul 30, 2011 at 08:26 AM 0
Share

Thanks for answering. What do you mean by "put the scale in the mesh node" ? Do you mean I have to move the vertex and keep my scale at Identity(1,1,1) ?

avatar image sneftel · Jul 30, 2011 at 10:21 AM 0
Share

No, I mean put the scale in the object with the mesh, not the object with children.

avatar image Cyrille-Paulhiac · Aug 03, 2011 at 07:08 PM 0
Share

Ben 12 has right, we have to avoid non-uniform scale at any costs !

I solve it creating a clone mesh (without scale) and just matching each vertex of the first mesh. So, the new mesh will have the scale of (1,1,1) and the vertex will ba where you want them.

A tricky way of doing $$anonymous$$ayas's "Freeze transformations".

avatar image
23

Answer by tyjkenn · Mar 15, 2013 at 03:11 AM

Create an empty GameObject. It has a scale of 1x1x1. Assign the scaled object as the parent. Then assign the empty GameObject as the parent to your desired child object. Now the Hierarchy should look like this:

 MyCubeAsParent
     EmptyGameObject
         MySphereAsChild

I tried this, and somehow it worked. Apparently it only scales the object according to the immediate parent's local scale. The code looked something like this:

 var emptyObject = new GameObject();
 emptyObject.transform.parent = myCubeAsParent.transform;
 mySphereAsChild.transform.parent = emptyObject.transform;
Comment
Comments Locked · 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 czilla0912 · Nov 12, 2013 at 07:58 PM 0
Share

I have been searching for an answer for this for a long time and this worked perfectly for me. Thanks tyjkenn!!!

avatar image mightysprite · Jul 03, 2014 at 12:50 AM 0
Share

The method that I used that was inspired by this answer was to build my hierarchy using non-scaled empty game objects and then hanging the meshes off of each node as appropriate. $$anonymous$$g. with a segmented character mesh your empty game objects would be shoulder, elbow, and wrist but your mesh pieces would be upper arm, lower arm, and hand. The upper arm is scaled as you want (which you might do if you're using primitives like the cylinder) and parented to the shoulder, the elbow is also parented to the shoulder and just offset however you wish. Then the wrist and the lower arm are parented to the elbow.

avatar image apostro · Feb 11, 2015 at 08:16 PM 0
Share

This worked as a charm, quick and easy solution. Thanks tyjkenn!

avatar image DevsGoingViral · Dec 08, 2015 at 07:27 PM 0
Share

Amazing simple solution,thank you so much!

avatar image SinopGames · Apr 01, 2017 at 10:27 AM 0
Share

thank you man. worked for me. thanks again.

avatar image
6

Answer by jbat100 · Feb 16, 2017 at 02:00 PM

You can store the scale before before parenting then reapply it, did the trick for me

 Vector3 scale = mySphereAsChild.transform.localScale;
 mySphereAsChild.transform.parent = myCubeAsParent.transform;
 mySphereAsChild.transform.localScale = scale;
Comment
Comments Locked · 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

Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

Object scale/rotation changes when parented to flipped object 0 Answers

How can I attach a gameobject to another without changing its scale. 1 Answer

Good way to scale parent without scaling children? 1 Answer

How to preserve size of children when changing scale of parent 5 Answers

Make gameobject a child without affecting scale? 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