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 coolthemanp6p · Dec 28, 2011 at 03:38 AM · terraingenerationminecraftblockmine

This script really makes my game lag!

 var grassBlock : Transform;

 function Update () {
 for(var grassLayerX = -5; grassLayerX < 5; grassLayerX++)
 for(var grassLayerZ = -5; grassLayerZ < 5; grassLayerZ++)
 {
     grassBlock = Instantiate(grassBlock, Vector3 (grassLayerX, 0,grassLayerZ)Quaternion.identity);
 }
 }

The original script had the grass layer variables at -500.

This script is supossed to generate a flat grass terrain from a prefab I made. But with the original it won't open. I tried compiling it and it would just come up with an errror screen I've never seen before saying : ERROR failed to initialize the player Could not preload global game manager #0. I think it's saying something about the build settings and level 0 but I did set the level to 0 in the build settings. Then I tried making it -5 in the script above and it works but it's SUPER laggy. The thing is it's not my computer because I just got a brand new one and it's has a really good processor and stuff all the newest parts and all other really HD games work smoothly.

So what's wrong is it because of the generation? Will it get better FPS after a minute or 2? Please help!

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
1

Answer by rabbitfang · Dec 28, 2011 at 04:58 AM

The reason it is so laggy is that it is creating 100 or so objects every frame. From looking at your code, you want to change Update() to Start().

P.S. I guess that the reason that the -500 value didn't work was because that would generate about 250,000 (500^2) objects.

EDIT: Also, it seems that you are trying to recreate Minecraft in Unity (based on your other questions). This is not a very good idea. Unity was not designed to do something like that, at least in the way you are going about it.

Comment
Add comment · Show 5 · 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 coolthemanp6p · Dec 29, 2011 at 05:10 AM 0
Share

I realized that I was using update not too long after I typed his up and submitted it. But still untiy wont create a lot of blocks :(

avatar image rabbitfang · Dec 29, 2011 at 05:56 AM 0
Share

There are only so many objects that Unity can handle. If you are doing a 500 by 500 grid, that is 250,000. This is not a good way of going about making $$anonymous$$inecraft.

avatar image coolthemanp6p · Dec 30, 2011 at 08:25 PM 0
Share

Is there any way to make this limit bigger?

avatar image rabbitfang · Dec 30, 2011 at 10:28 PM 0
Share

Not really. You need to go about recreating $$anonymous$$inecraft a different way.

avatar image Simon V · Dec 30, 2011 at 10:48 PM 0
Share

$$anonymous$$inecraft works with chunks of - I believe - 32*32 block columns, and loads a few of these. The rest is saved in the savefile. They probably also have very efficient rendering and memory handling algorithms. Which are probably very hard to recreate in Unity.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

2D Procedural Terrain Generation 1 Answer

How can I rename an object without renaming every single one for block generation? 0 Answers

World Generation with Interesting Terrain 0 Answers

Minecraft (Cube) Terrain 1 Answer

(script) how to get terrain to turn into blocks 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