Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Catlard · Nov 12, 2011 at 10:24 AM · transformscalechildrenparenting

Child objects with different scales move differently?

Let's say I have two identical cubes--each of which have a scaled down cube as a child. On one parent cube I place a script that moves the cube 10 units up. On the other parent cube's child I place the same script. On the first cube, both of the cubes move up 10 units, when I hit play. But on the second cube, when I hit play, only the child moves, right? Right. Except the second cube's child moves much more than 10 units up. Looks more like it's related to the ratio of itself to it's parent's scale. At the same time, it's still saying it's moving only 10 units. CONFUSIONTOWN.

What gives? Is this a feature? If it is a feature, what would it be useful for? How do I stop this scaling and moving effect from happening? Why would I not want to know exactly how many units it was actually moving? I was using empty parented game objects as a means to organize things in the hierarchy, but now I'm just scared.

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

2 Replies

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

Answer by aldonaletto · Nov 12, 2011 at 04:32 PM

How are you moving these cubes? If you modify localPosition, yes, the childed cube will be moved by displacement * parent scale. When you child an object, its transform.localScale (transform.scale doesn't exist) is divided by the parents scale to keep the relative proportions - if you scale the parent, the child will be scaled proportionally.
You can move the child using transform.Translate, or even transform.position - they're not affected by the parent scale.

Comment
Add comment · Show 4 · 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 Catlard · Nov 13, 2011 at 02:18 AM 0
Share

AH! Excellent stuff to know. But I am moving it by transform.position...and that's what's causing the effect. I still don't understand why I would ever want not to know the "real" height independent of scale, you know? Seems like it might be useful for some game concepts, but not the majority of them...yeah?

avatar image aldonaletto · Nov 13, 2011 at 10:19 AM 0
Share

With transform.position? Weird thing: I tested this, and only localPosition took scale into account (as expected): transform.position and transform.Translate ignored the scale, and resulted in the same displacements in different scales.

avatar image Catlard · Nov 13, 2011 at 10:53 AM 0
Share

Hmm...so are we agreed, there is something weird going on here? What do you mean by "the same displacements in different scales"?

avatar image Catlard · Nov 13, 2011 at 10:54 AM 0
Share

gameObject.transform.position.y was what I was using to access it the whole time I've never used localPosition, as I'm not really sure what it needs to be used for.

avatar image
0

Answer by sweatyrat · Jun 15, 2012 at 04:05 PM

as to why it is useful, if you have a huge map like a solar system, the vector3 transform cant hold all the precision you need for far away object. but if you make your game a series of layers such as the solar system has sector children and all objects are in some sector then you set the sector objects scale to 1 and the solar system scale to 10000 then sector1 for example is just 1 sun local position unit away but its 10000 away in base units so your player object is at its sectorlocalposition+sunlocalposition*10000 and it keeps a high level of precision at huge distances that would not work otherwise.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How is localScale adjusted when re-parenting transforms? 2 Answers

How to smooth transform scaling with 2d sprite 1 Answer

TextMeshPro Height 0 Answers

Is Physics.SyncTransforms() automatically called in built game? 0 Answers

Can you change to order of children? (Insert a new child) 4 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