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 Jeremy 7 · Jan 13, 2011 at 02:56 AM · scaleparentchild

How to make parent scale inversely affect child scale?

Hi. Hope this is quick since it seems like an easy question.

I have two objects in a parent/child hierarchy that I created by dragging one object onto another in the Unity editor then saving the whole thing as a prefab. The child object has a visual aspect to it, but not the object it is under.

In a new scene I am scaling the prefab in the X direction. This visually scales the child object as well. What I would like to do is have the child object detect how much the top object is scaled by in the X direction, then divide its own scale by that number.

So if I were to scale the prefab to 5 in the X direction, the child in the prefab would (upon playing the scene) divide its X scale by 5.

What do I put on the second object to have it find the first object's scale? I'm not sure if it is considered a true parent/child relationship in the javascript since I did not make that distinction in code. Once I have the scale of the "parent" I'm golden since the rest is just division.

Thanks!

Comment
Add comment · 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 Bunny83 · Jan 13, 2011 at 03:26 AM 0
Share

Take a look into the scripting documentation, the Transform component is all you need ;) http://unity3d.com/support/documentation/ScriptReference/Transform.html

1 Reply

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

Answer by Bunny83 · Jan 13, 2011 at 03:22 AM

i guess you need this on your child object to get the parents scale:

transform.parent.localScale

I don't understand why i would scale a parent GO with no visual effect and want to keep the childs scale constant. Maybe just reverse the hierachy? Having the visual object outside and the one you want to scale inside don't produce that problem. If that's not possible you have to scale the child as you described above ;)

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 Jeremy 7 · Jan 13, 2011 at 03:59 AM 0
Share

I was actually leaving out the use I have for the parent since I didn't think it important to what I was asking. While it has no visual aspect, it is used for something else and it needed to be the parent for the visual object. Thank you!

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

No one has followed this question yet.

Related Questions

Make a simple tree 1 Answer

Scale child while ignoring the parent? 2 Answers

Good way to scale parent without scaling children? 1 Answer

Parenting issue: Building and windows (scaling them as a whole entity) 1 Answer

How to Prevent Child Deformation on Rotate? 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