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 /
avatar image
3
Question by GesterX · May 22, 2011 at 02:30 PM · scalelocalscale

How can I scale my object "upwards"?

I am using localScale.y to scale a cube but I would like the scaling to make the cube "taller" rather than the current way which ends up with half of it through the floor This is most easily explained with a picture. (1) is the original cube. (2) is what I want. (3) is what I get.

cubes

Now I do understand why this happens. The cube is scaled from the center point in both directions equally.

My app is a music visualisation program so the scaling happens a few times per second so I don't think it is poissible to keep on correcting the y position of the cube else the cube will be out of place when the cube gets smaller.

Is there a nice way to change how the cube is scaled or a workaround for this?

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

3 Replies

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

Answer by DaveA · May 22, 2011 at 02:46 PM

Actually, yes, you can change the y position, it updates very quickly, should be just fine. But if that is really not what you want to do for some reason, a) model the cube with Blender or other 3d program, where the origin is at the bottom, or b) put the cube into an empty gameobject, offsetting it upward .5, so the new gameobject, when at 0,0,0, has a cube in it that sits 'on the ground', then scale that containing object instead.

Comment
Add comment · 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 GesterX · May 22, 2011 at 03:09 PM 0
Share

I think I'll go for option B. The scaling is happening according to my spectrum data so it's tricky to tell how much I should move it on the Y axis each time (unless there is a way to get the translation directly based off the scale?)

avatar image Joshua · May 22, 2011 at 04:13 PM 2
Share

Of course there is, GesterX. With a y-scale of 1 the origin is at 0.5 and the 'floor' is at 0. If the y-scale is 2 the origin is at 1, Etc.

So every time you scale simply put the y position at the y-scale*0.5

avatar image UnseenBeyond Joshua · Mar 18, 2020 at 11:17 PM 0
Share

doesnt work at all, got a better forumla?

avatar image
8

Answer by Zhapness · May 22, 2011 at 03:22 PM

You should just do:

transform.position.y = 0 + transform.localScale.y/2

that way the object will start at point 0 no matter its size.

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 sumnone · Jun 09, 2012 at 06:38 PM 0
Share

Works perfect...Thank you for such a simple solution.

avatar image UnseenBeyond · Mar 18, 2020 at 11:02 PM 0
Share

doesnt work at all

avatar image
0

Answer by Abdullah Sattar · Sep 25, 2013 at 12:23 PM

Hello. The above mentioned technique is also a solution but if you have any designer or any know how to use 3ds Max or Maya you can set the pivot point of that object to the bottom which you mentioned earlier (Cube), and just scale it upwards then see it will only scale in the upward direction and the bottom positioning will remain un-effected. Set Pivot point to the bottom of the cube or opposite to the side in which you want to scale which is bottom.

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

6 People are following this question.

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

Related Questions

scale gameobject with particle system as child 0 Answers

How to make an object's localscale values grow and shrink within a few seconds? 0 Answers

problem Changing Scales in Script -C# 4 Answers

Object's localScale 1 Answer

Rescaling goes wrong? 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