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 wijesijp · Apr 05, 2013 at 08:56 AM · scaleresizelocalscaledistorted

Resize object in runtime

I have 4 rigid bodies connected with hinge joints. They are children to an empty parent object.

When I scale the parent at run-time using localScale the relative positions of the child objects get change.

But if I scale it in editor it works out fine.

Can anyone explain why this is happening ?

alt text

object.png (7.9 kB)
Comment
Add comment · Show 4
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 wijesijp · Apr 05, 2013 at 11:10 AM 0
Share

can anyone provide some help on this ?

avatar image benni05 · Apr 05, 2013 at 11:51 AM 0
Share

Could you please explain what you mean by "of the child objects get change(d)" ? Changed in which way? What do you consider wrong with this?

The same goes for "it works out fine." What does fine mean?

avatar image wijesijp · Apr 05, 2013 at 12:14 PM 0
Share

I use following code to resize in run time

 o =(GameObject)Instantiate(tObj,trans.position,Quaternion.identity);
 o.transform.localScale = new Vector3(5,5,5);



This is what happens. The object is rotated differently but you can see that the child objects are cutting into each other. Their relative positions are off ...

alt text

The same goes for "it works out fine." What does fine mean?

I can resize the object to any size in editor. It will retain the child object relative posistions

If I can resize object to 5 in editor and it works fine why can't I do the same in run time?

[2]: /storage/temp/9738-object.png

object.png (6.8 kB)
avatar image wijesijp · Apr 05, 2013 at 05:47 PM 0
Share

Yes that's exactly what was happening ...

Thanks for suggesting it

1 Reply

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

Answer by benni05 · Apr 05, 2013 at 01:15 PM

I assume you do the resizing at runtime (the code above) only once in the Awake or Start method, right?

Your problems might have to do with the Rigidbodies you are using. They are part of the Physics engine Unity is offering. You should manipulate them preferably only in a FixedUpdate() method of MonoBehaviour (or as I said in the Awake or Start method before the Update calls are running). Try to set the Rigidbodies to isKinematic = true before resizing and afterwards switch the isKinematic off again and see whether this avoids the problem.

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 benni05 · Apr 05, 2013 at 10:47 PM 0
Share

Changed my comment to answer then, feel free to accept it as such. Thank you.

avatar image skeletromp · Feb 25, 2015 at 11:46 PM 0
Share

Did this answer work for anyone?

I'm having the exact same problem and I tried what is suggested here with no luck. I'm only changing transform.localScale in the Start method and before I do, I make all affected rigidbodies kinematic. Then apply the scale change. Then make the same rigidbodies non-kinematic.

I've also broken the steps down at runtime to see what happens. When the rigidbodies are kinematic and the scale is changed, the character looks as it should - all of the hinge joints are anchored in the ways that makes the character look right. As soon as the rigidbodies are made non-kinematic, the joints snap back to what appears to be their original locations pre-scaling. Though as was wijesijp's experience, if this scale change is done in the editor, everything works great.

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

12 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

Related Questions

How to resize nested sprite 1 Answer

Asset Automatically Re-Sizing (On it's own) 1 Answer

Smoothly changing scale on an arbitrary mesh - mobile 1 Answer

size of gameobject in unity 1 Answer

[Question]Scaling Limits 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