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 Blaque · Jan 28, 2015 at 11:30 AM · animationguirotatecircledeformation

Rotating guiTexture around a point in circle

Not knowing where to turn, i decide to post a question here

I got an empty gameObject where is located at (0.5, 0.5, 0), this gameObject also have a script, which create a random number of 2d texture with empty gameOjbject childs, then by the following code i set them one equidistant from another:

 for (var i : int = 0; i < transform.childCount; i++){
         transform.GetChild(i).localPosition = Vector3((xActivePositions[i]) * 0.2 * ringID, (yActivePositions[i]) * 0.2 * ringID, 0);
     }

Where ringID is the radius and the array used are predefinited positions around a circle for example with 4 texture the arrays will be:

for the x [0f, -1f, 0f, 1f];

for the y [1f, 0f, -1f, 0f];

with 5 instead:

for the x [0, -0.95, -0.58, 0.58, 0.95];

for the y [1, 0.3, -0.8, -0.8, 0.3];

I achieve to set texture position around the point correctly but for the gui coordinates system what i create is not a circle but an oval deformed to fit the screen

What i want is to create a perfect circle in the middle of the screen, so that it fit a 1/3 of vertical space Then i start to modify randomly the code abowe, its seems that i obtain a circle dividing the y obtained by 2 So i obtained a circle, but i have to rotate texture around the center, i use this code:

 function rotate(degrees : float, duration : float, anticlockwise : boolean){
     if (busy) return;
     busy = true;
     var startTime : float = Time.time;
     var startY : float = transform.rotation.eulerAngles.z;
     var rotating : float = 0;
     while (rotating < 10){
         var t : float = (Time.time - startTime) / duration;
         rotating += t;
         if (anticlockwise) transform.rotation = Quaternion.Euler(0, 0, Mathf.SmoothStep(startY, startY + degrees, t));
         else transform.rotation = Quaternion.Euler(0, 0, startY - Mathf.SmoothStep(0, degrees, t));
         yield WaitForSeconds(0.0001);}      
     } busy = false;

This code works for me but:

-When my gui is setted as oval, the texture will rotate perfectly but i want to rotate around a circle

-When i adjust the code to make a circle, when i rotate, the circle will deform assuming a strange shape, only on 360 degree the texture are posed like a circle

Dividing the y position by 2 in the for circle i obtain a circle-like alt text

So i try the rotate method, since there are 5 elements i'll call it with 72 degrees, clockwise but i'll obtain this deformation: alt text

Really don't know what the heck happend, it will return to a circle only rotating 360 degrees Don't know if its related but the texture use this code to adjust fot the screen:

 guiTexture.pixelInset = new Rect(- Screen.width / 16, - Screen.width / 16, Screen.width / 8, Screen.width / 8);

How can i rotate the texture around the point moving in circle properly?

I did my best to explain myself, sorry for my english too

screenshot-2015-01-27-223244.png (58.9 kB)
screenshot-2015-01-27-223626.png (61.1 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

GUIUtiliy.RotateAroundPivot() doesn't work 0 Answers

Rotate Texture 1 Answer

Create 3D GUI Button? 2 Answers

Size GUiLayout 2 Answers

How to plot velocity of vehicle wheel collider on realtime graph 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