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 /
This question was closed Jun 24, 2013 at 12:23 PM by Em3rgency for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Em3rgency · Jun 24, 2013 at 10:47 AM · c#gameobjectscenechild

Parent-child scaling problem (Solved)

So I have child objects that are essentially the same model and size of the parent, just different textures.

My problem is, when I instantiate a child from code, it uses its scale values as absolutes, BUT when I drag a child into the scene, it uses the scale relative to the parent ( (1,1,1) would be the same as parent ).

So if I have an object scaled x2, y10, z10, and the child with the exact same values, spawning the child with code gets be an object the size of (2,10,10), but dragging the child into the scene gets me an object the size of (4, 100, 100) and I have to manually reset the values.

The best way to fix this would be to make the code also use relative scaling, so I could just set the child's scale to (1,1,1) everywhere. How would I go about doing this?

Comment
Add comment · Show 3
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 Quaker_SDR · Jun 24, 2013 at 12:09 PM 1
Share

Use transform.LossyScale..

avatar image kursion Quaker_SDR · Jan 21, 2016 at 02:10 AM 0
Share

Can you show an example please ?

avatar image Em3rgency · Jun 24, 2013 at 12:22 PM 0
Share

Used

 child.localScale = parent.transform.localScale;

after the instantiation, as that was what I needed. Now my objects drag and instantiate into the scene all the same size. Thank you for getting me on the right track! No clue how I managed to miss that method...

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Quaker_SDR · Jun 24, 2013 at 12:32 PM

use transform.LossyScale to assign it back to original size.

Comment
Add comment · Show 1 · 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 kursion · Jan 21, 2016 at 02:10 AM 0
Share

Can you show an example please ?

Follow this Question

Answers Answers and Comments

17 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

Related Questions

I have an error, script should check for null or not destroy game objects 2 Answers

[C#] An error occurs when trying to set a child to my GameObject in script. Why? 0 Answers

Calling an Audio Source on one game object from a script on another game object..? 1 Answer

"Center On Children" programmatically 1 Answer

Destroying childs and Instantiate [C#] 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