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 cCoding · Dec 09, 2013 at 11:54 PM · c#gameobjectarrayplaneprimitive

Making an array "spread" out evenly?

How do I properly make an array "30x30" of planes are spread out evenly? The one and only issue i'm having is that the planes are overlapping each other by 3 units. How do I properly make sure the planes are butted up to each other and not overlapping?

General array while game is running-

https://www.dropbox.com/s/jssag7zadi0kxyr/Screenshot%202013-12-09%2018.30.26.png

One of the arrays highlighted to show overlapping-

https://www.dropbox.com/s/bl2s27p9433lv0l/Screenshot%202013-12-09%2018.31.55.png

Array Code:

 public void grid_array ()
 {
      for (int x = 0; x<grids_x; x++) {
           for (int z = 0; z<grids_z; z++) {
                GameObject grid_plane = GameObject.CreatePrimitive (PrimitiveType.Plane);
                grid_plane.renderer.material = pgrid_mat;
                grid_plane.transform.localScale = new Vector3 (0.5f, 1f, 0.5f);
                Vector3 grid_vector = new Vector3 (x - 15, 0, z - 15);// grids_x & z = 30 and I want the array to be centered.
                grid_plane.transform.position = grid_vector;
                Debug.Log ("Grid Draw: " + grid_vector.ToString ());
               }
        }
 }


EDIT:

The answer to fixing this was just add "*5" to the end of "grid_plane.transform.position = grid_vector;".

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 Statement · Dec 10, 2013 at 12:05 AM

You need to take the size of each plane into account.

  • They are 10x10 units.

  • You scale them to half the size.

  • Position them 5 units apart

Example:

 Vector3 grid_vector = new Vector3 (x - 15, 0, z - 15);
 grid_vector *= 5;
Comment
Add comment · Show 1 · 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 cCoding · Dec 10, 2013 at 12:12 AM 0
Share

You need to take the size of each plane into account.

Yea I had a feeling this was the case. I tried multiplying both grids_x & grids_z by different numbers to see if that would work. I didn't try doing anything to "grid_plane.transform.position = grid_vector;". Quite interesting that the only thing I needed to do was this "grid_plane.transform.position = grid_vector * 5;".

I appreciate the help! Ill make sure to add the answer to my OP.

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

17 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

Related Questions

How to set to game objects's position from 2 different game objects arrays equal to each other? 0 Answers

How to select an Game Object from an Item List 0 Answers

How can i get ONLY the childrens of a GameOnbject with GetComponentsInChildren method? 5 Answers

Read different game objects into array at same time? 2 Answers

C# Plane Detecting a Gameobject 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