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 /
avatar image
0
Question by Fabianlindfors · Aug 11, 2011 at 10:34 AM · cubegeneration

Block ground generation

I have written a very simple script to make a ground of blocks.

 var object : GameObject;
 
 function Start () {
     for(var x = 0;x < 100;x++)
     {
         for(var y = 0;y < 100;y++)
         {
             var cube = Instantiate(object,Vector3(x,y,0),Quaternion.Identity);
         }
     }
 }

The object variable is the prefab that it should make the ground out of. In this case a cube. But when i run it there is no ground. And I am at 0,0,0 position in the world.

Comment
Add comment · Show 1
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 Statement · Aug 11, 2011 at 11:03 AM 1
Share

This would not create a ground. It would create a wall.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Statement · Aug 11, 2011 at 11:06 AM

It seems you're building a wall. x is left, y is up and z is forward. so you want to create them along the x/z axes. Also object is a reserved keyword in C#, I don't know how this translates to JS... But try renaming the object variable.

 var prefab : GameObject;  // Renamed, because of uncertainty
 var height : float = -1.0f; // Adjust this to find a proper height...
 
 function Start () {
     for(var x = 0; x < 100; x++)
         for(var z = 0; z < 100; z++)
             Instantiate(prefab, Vector3(x, height, z), Quaternion.Identity);
 }


Comment
Add comment · Show 7 · 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 Fabianlindfors · Aug 11, 2011 at 11:27 AM 0
Share

Oh right yes i would create a wall but still nothing!

avatar image Statement · Aug 11, 2011 at 11:59 AM 0
Share

Well this is odd. Put a print("Hello world") inside Start to see if it runs at all. Is your script enabled?

avatar image Fabianlindfors · Aug 11, 2011 at 12:00 PM 0
Share

Oh im gonna try the console checking thingy :p

avatar image Fabianlindfors · Aug 11, 2011 at 12:08 PM 0
Share

I get a null reference error.

avatar image Fabianlindfors · Aug 11, 2011 at 12:08 PM 0
Share

But I have set the prefab variable

Show more comments
avatar image
0

Answer by Fabianlindfors · Aug 13, 2011 at 12:28 PM

It turned out that I used a capital I in Quaternion.identity ! Damn case sensitive!

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 Statement · Aug 13, 2011 at 02:42 PM 0
Share

And you got a null reference exception for that? JS doesn't fail to surprise me :)

avatar image Fabianlindfors · Aug 14, 2011 at 12:45 PM 0
Share

Damn wierd but my instantiation is really slow! I instantiate 200 cubes at start but it takes like 10s to load! $$anonymous$$y computer is not slow!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Problem with floor generator. 2 Answers

Cube made out of many voxels 0 Answers

Generate cubes in 5 areas 1 Answer

Mapping Cube to Sphere - Using 64 planes as a cube "side" 1 Answer

Generating a grid of cubes with space between. 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