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 /
  • Help Room /
avatar image
0
Question by LazyBassTurd · Jul 20, 2016 at 09:55 AM · mathcircular

struggling with the math

This may be a little difficult to explain, I have a ring of square sprites which I would like to expand outwards while keeping a uniform distance between sprites and scaling them up from 0.5 (inner most ring) to 1 (outer most ring). I'm not really that good with maths just yet so, any help on achieving this would be greatly received.

alt text

 using UnityEngine;
 using System.Collections;
 
 public class test : MonoBehaviour {
 
     GameObject areaGo;
     GameObject areaSprite;
 
     public Sprite sprite;
 
     int areaAmount = 120;
     int layerAmount = 10;
 
     float angle = 0f;
     float angleOffset = 3f;
     float intialPosition = 10f;
     float initialScale = 0.5f;
 
     void Start () {
 
 
 
         for (int i_layer = 0; i_layer < layerAmount; i_layer++)
         {
             for (int i_area = 0; i_area < areaAmount; i_area++)
             {
                 areaGo = new GameObject();
                 areaGo.name = "area_" + i_area;
 
                 areaSprite = new GameObject();
                 areaSprite.name = "areaSprite_" + i_area;
 
                 areaSprite.transform.parent = areaGo.transform;
                 areaSprite.AddComponent<SpriteRenderer>().sprite = sprite;
                 areaSprite.AddComponent<BoxCollider2D>();
 
 
 
                 areaSprite.transform.position = new Vector3(0f, intialPosition, 0f);
                 areaSprite.transform.localScale = new Vector3(initialScale, initialScale, 0f);
 
 
 
                 angle = +angleOffset * i_area;
                 areaGo.transform.Rotate(0f, 0f, angle);
 
                 Debug.Log(angleOffset);
             }
 
             intialPosition += 0.55f;
             // initialScale += 0.005f;
         }
 
     }
     
 }

example.png (37.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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by JamesLawrenceMyQVO · Jul 20, 2016 at 02:13 PM

I'm not sure I understand exactly what you want. Is the example .png what you want it to be, or just how the squares are arranged? If they are square, they won't maintain a uniform distance between them over the length of the square, let alone over multiple radius concentric circles of the squares. Can you give a small example with maybe 8 or so sprites to show what you are going for?

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
avatar image
0

Answer by LazyBassTurd · Jul 20, 2016 at 04:56 PM

I changed it to start from the outer most ring (concentric circle) and go inwards and I'm getting close the first three rings seem ok but, it still goes off after a few rings.

alt text


example2.png (132.9 kB)
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

65 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Predict the hit position 0 Answers

Spawn Objects on Grid - how to define size? 1 Answer

Check if a point is on the right or left of a vector? 2 Answers

How do I find a point along a line with a forced x and z values 0 Answers

Reading a flowmap with script vs shadergraph 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