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 awplays49 · Feb 12, 2016 at 09:31 PM · 2drendering

Why is my 2D voxel game terribly unoptimized?

Up until recently, it has been fine. However I opened up the project today and I hit play, and it took about 12 seconds to run. The grid of tiles adds up to 16^2 8 16. However I've already generated it and I'm not regenerating it on start. In fact, none of the tiles are programmed to do anything upon start. I use a sprite material I made with pixel snap to render them. I just wonder if the population of my scene as of now is too large to run all at once. I even tried deactivating all my tiles and running, but no luck. Anyways hope this can get resolved. Thanks!

-Edit-

For some reason the scripts attached to each individual tile is what is causing this. Is there a way to optimize this, or should I make a manager that handles this stuff?

Comment
Add comment · Show 5
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 Cherno · Feb 12, 2016 at 09:36 PM 0
Share

Are you using seperate GameObjects for each tile by any chance?

avatar image awplays49 · Feb 12, 2016 at 09:56 PM 0
Share

@Cherno yes

avatar image awplays49 · Feb 12, 2016 at 10:29 PM 0
Share

@Cherno i assume from your comment that there's another way to do this. Could you inform me on how others could possibly achieve these tiles?

avatar image Jessespike · Feb 12, 2016 at 11:07 PM 0
Share

For voxel-based environments, the common technique is create "chunks" by combining many individual meshes into one larger mesh.

avatar image Cherno Jessespike · Feb 14, 2016 at 12:48 PM 1
Share

Generally, it goes like this:

You have a two- or three-dimensional array, where each element hold information about the cell/tile at position x,y(,z). If, for example, you want to access the tile that the cursor is pointing at, you would convert the cursor position to world space and use it to get the x,y coordinates in your array. You create a mesh, or multiple meshes (chunks) by going through each tile of your array and create a plane or cube (or anything else) at the current x,y position.

There are dozens of tutorials for this, search for "procedural mesh generation" and similar terms.

1 Reply

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

Answer by Zoogyburger · Feb 12, 2016 at 10:00 PM

Why are there scripts attached to every different tile? Why not make all your tiles one game object by checking tiles as "static" I got a better performance.

You might want to try this program for tilesets:

http://www.mapeditor.org

and import the maps you make using

http://www.seanba.com/tiled2unity

to learn how to use this go to

https://www.youtube.com/watch?v=NNpLsimyu3I&list=PL_4rJ_acBNMH3SExL3yIOzaqj5IP5CJLC

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 awplays49 · Feb 12, 2016 at 10:28 PM 0
Share

Hey @Zoogyburger,

How could I possibly attach a script to something else rather than all the tiles? The tiles have to detect when they're broken, how else could I do it?

avatar image awplays49 · Feb 12, 2016 at 10:33 PM 0
Share

I don't need those programs I'm sure there's a way to do this. I just don't know how.

avatar image Zoogyburger · Feb 12, 2016 at 11:09 PM 0
Share

$$anonymous$$ake your tiles children of an empty gamobject add your script to it with this line of code:

 void Start (){
         
     foreach (Transform child in transform)
     {
         child.gameObject.AddComponent<scriptname>();
     }
 }

}

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

59 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

Related Questions

Sprite not visible from behind 0 Answers

My camera not rendering anything in Custom render type,I have an issue: 0 Answers

How do I make one light source override all other light sources? 0 Answers

How to Display Hundreds of Thousands of Sprites? 2 Answers

Mesh with vertices changed in script is not rendered 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