• 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 Daniel-Talis · Sep 03, 2012 at 01:51 AM · cubes

Create a Cube of Cubes

Hi There, I thought of an idea and then wondered how I could get it into Unity and have hit a block, mainly because of my lack of mathematical ability. Perhaps someone can help on this..

Basically it is a Cube 1000x1000x1000 and is made up of smaller Cubes 1x1x1. I started placing Cubes beside each other and soon discovered.. it's going to take a while..Is there a mathematical quick way to do this?

That's the first part. Then I need to texture each Cube individually. Is this even possible when there are so many? I need to be able to identify a Cube in a coordinate system and read it's texture.

Thanks.

Comment
Add comment · Show 3
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 Daniel-Talis · Sep 03, 2012 at 04:48 AM 0
Share

Hi Fattie, The idea is to have a visual coordinate system where One either teleports or flys to a particular coordinate and reads information (textured on a Cube). A sort of Borg Library. :)

avatar image Eric5h5 · Sep 03, 2012 at 05:19 AM 0
Share

For "great exercise" substitute "great way to get RSI". ;)

avatar image Daniel-Talis · Sep 03, 2012 at 06:44 AM 0
Share

Hi Fattie, That was a rave. All good though because I picked a 1000x1000x1000 Cube as it's such a beautiful round number and the $$anonymous$$imum really for an area to travel around in. So thanks for that and I am aware of the 'grey effect' that can be achieved from a distance although just how to mix up that effect with a bunch of real Cubes is still a little out of my grasp. However, I've come up with an idea which may either astound or make make readers yawn. I'll run it by...

The information I require to be on Cubes can actually be on twenty-seven cubes. So if I make a Cube 3x3x3 Cubes and through a cunning system of moving three long cylinders, I can establish where the Cube of 27 should be within the empty one square kilometer then move it there using code and with a simple calculation the particular Cube amongst the twenty-seven can be pinpointed and the information gained. If it works, I'll make a post on the Unity Forum with a Demo.

4 Replies

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

Answer by Daniel-Talis · Mar 08, 2015 at 01:25 AM

I found a solution to this. An asset on the Asset Store called 'Endless Universe".

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
1

Answer by GlitchBait · Sep 03, 2012 at 02:08 AM

 //This creates a large block of objects.
 //Add script to an empty object. The creation of the this script will be in releation to where the empty block is placed.
     var prefab         : GameObject; 
     var cubeSize    : int     = 5 ;
     var offset         : int     = 1 ;    //Distance between cube centers
 
     function Start(){
 
         for (var zz = 0;zz<cubeSize*offset;zz+=offset){
 
            for (var yy = 0;yy<cubeSize*offset;yy+=offset){
 
              for (var xx = 0;xx<cubeSize*offset;xx+=offset){
 
                 // Begin the instantiation where the empty object is. 
                  Instantiate (prefab, Vector3(transform.position.x + xx, transform.position.y + yy, transform.position.z + zz), Quaternion.identity);
 
                    //Added this line so you can actually see how the cubes are being populated
                   yield WaitForEndOfFrame;    
 
              }    
            }
         }
     }
 
Comment
Add comment · Show 3 · 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 GlitchBait · Sep 03, 2012 at 02:12 AM 0
Share

This will instantiate any number of cubes to create a larger cube. I use this for quick tests.

I wouldn't suggest having that many objects without Unity Pro as the free version doesn't have occlusive culling (I believe that's what it's called). With the free version, the player has to process everything in the scene, even if it's not in line of sight.

Good luck!

avatar image Daniel-Talis · Sep 03, 2012 at 02:22 AM 0
Share

Thanks, Just tried your code. It works fine so far, will experiment further.

avatar image Eric5h5 · Sep 03, 2012 at 02:36 AM 0
Share

Occlusion culling only works for static objects that are created in a level; it won't work for objects that are dynamically generated.

avatar image
1

Answer by Eric5h5 · Sep 03, 2012 at 02:39 AM

You won't be able to make 1000x1000x1000 separate objects, not even close. You realize that's 1 billion objects, right? ;) If you're trying to do something like Minecraft, you have to build meshes using the Mesh class, and be smart about not creating geometry that you won't see anyway.

Comment
Add comment · Show 6 · 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 Daniel-Talis · Sep 03, 2012 at 02:48 AM 0
Share

Yes, that's a lot of Cubes. For some reason I thought I could use 'clipping planes' or some such amazing feature to achieve this. Actually what I'm trying to create is a visual coordinate system. Where I can go to a particular coordinate and view the properties( texture) of the Cube at that coordinate.

avatar image Bunny83 · Sep 03, 2012 at 02:49 AM 0
Share

So basically another case for the Unity $$anonymous$$ineCraft Starter Package

avatar image Daniel-Talis · Sep 03, 2012 at 02:59 AM 0
Share

I'll have a look through this package.

avatar image Eric5h5 · Sep 03, 2012 at 03:13 AM 0
Share

Instantiating objects is fairly expensive; things will start seriously slowing down around 10$$anonymous$$ objects, so ideally you don't want to go beyond a few $$anonymous$$ at most.

avatar image Bunny83 · Sep 03, 2012 at 03:18 AM 0
Share

Besides that the visual amount is way to much, have you even thought about the memory? 1000x1000x1000 means even when you only store 1 byte per cube you would need 1GB. Since each cube is a GameObject in your case you have a lot more per object. Lets just count the Transform component: position(3), rotation(4), scale(3) That means 10 float values. Each float needs 4 byte --> 40bytes per cube (just the Transform component without any additional overhead) --> 40GB There's a reason why $$anonymous$$ecraft has an y limit of 128 and a max view distance ;)

 Far: 400
 Normal: 256
 Small: 128
 Tiny: 64
Show more comments
avatar image
0

Answer by blastoformity7 · Jun 26, 2016 at 06:00 AM

SPAWN A CUBE OF CUBES .

 public Transform cubePrefab;

 public int rows,columns,depth;
 public float padding;

 // Use this for initialization
 void Start () {
     for(int i =0; i < depth; i ++) {
         for(int j=0;j< columns;j++){
             for(int k=0; k < rows;k++){
                 Vector3 pos = new Vector3(k * padding,j * padding,i * padding);
                 //print(pos);
                 Transform foo = (Transform) Instantiate(cubePrefab,pos,Quaternion.identity);
             }
         }
     }
 }
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 Eric5h5 · Jun 26, 2016 at 06:30 AM 0
Share

Yeah, that's not any really different from the other answer from 2012, which has the severe drawback of creating zillions of separate objects.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Need to make a a board of 6x6 cubes 1 Answer

Cube 2.5D platformer - performance & mesh alignment issues 0 Answers

Block-based terrain: WWW image problem and performance help? 0 Answers

How to properly do collision for placing object 0 Answers

Rotating a cube horizontal axis 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