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 oliver-jones · Nov 21, 2010 at 12:43 AM · collidertransformscalemathradius

Simple Maths Problem - Help!

Okay, I've got a plane with a texture applied to it, and I want to scale the plane according to a sphere collider I have. BEFORE you read ahead, please note that the texture fits perfectly around the sphere collider (texture is a ring) at radius 10 so I have been working around '10', so for example, if the radius equals 9, then Scale / 9 * 10 = The New Scale for that current radius. The problem I'm having is that, at radius 10, the texture fits fine. But if I choose anything lower than 10, so, 9 - the texture grows bigger, not smaller. And vise versa, radius 11 - texture is smaller.

Code:

var RadiusObject : Transform; private var CurrentSize : float;

private var ScaleX = 2; // These are the texture size when they fit perfectly at 10 private var ScaleY = 0; //--not worried about this, its always 0--\\ private var ScaleZ = 2.3;

private var ScaleXDiv : float = 0; //These are the new scale size private var ScaleYDiv : float = 0; private var ScaleZDiv : float = 0;

function Update () { CurrentSize = collider.radius;

 ScaleXDiv = (ScaleX / CurrentSize) * 10;
 ScaleZDiv = (ScaleZ / CurrentSize) * 10;


 RadiusObject.transform.localScale = Vector3(ScaleXDiv,ScaleY,ScaleZDiv);

}

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

1 Reply

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

Answer by oliver-jones · Nov 21, 2010 at 01:05 AM

Solved it my self ... Soo Simple, haha I just had to reverse the formula (with some slight moderation:

var RadiusObject : Transform; private var CurrentSize : float;

private var ScaleX = 2; private var ScaleY = 0; private var ScaleZ = 2.3;

private var ScaleXDiv : float = 0; private var ScaleYDiv : float = 0; private var ScaleZDiv : float = 0;

private var ScaleXNew : float = 0; private var ScaleZNew : float = 0;

function Update () { CurrentSize = collider.radius;

 ScaleXDiv = (ScaleX * CurrentSize);
 ScaleXNew = ScaleXDiv / 10;

 ScaleZDiv = (ScaleZ * CurrentSize);
 ScaleZNew = ScaleZDiv / 10;

 RadiusObject.transform.localScale = Vector3(ScaleXNew,ScaleY,ScaleZNew);

}

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 Herman-Tulleken · Nov 21, 2010 at 02:02 PM 0
Share

If you solved it, mark it!

avatar image oliver-jones · Nov 22, 2010 at 07:14 PM 0
Share

I had to wait 42 hours! Else I would of

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

how to scale object to fit inside a room 1 Answer

Sprite doesn't flip correctly. 1 Answer

Ignore Collision Temporarily 1 Answer

Normalise a value 2 Answers

Shear transformation using GameObject transformations 2 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