Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 SpringOfLife · Jun 04, 2020 at 03:38 PM · 2dtilemapprocedural generationperfomance

Best way to handle large tilemap?

Hi everyone,

I need your help to understand the best way to build a large tilemap.

Baseline: I'm trying to build a top down 2d game with procedurally generated tile map. The map size would be around 8000x8000 tiles. There can be several characters at the map and you can switch between them. But generally the whole map will never be loaded or visible to a player - only a small area like 50x50 tiles.

Approaches: So I figured out the best way to implement this is to divide map into chunks and only load some of them at a time. However I'm struggling with the best way to render it.

I know having a mesh per chunk is a pretty good and fast solution. But I'm afraid there's going to be some problems around mesh+tiles ordering and sorting.

So I thought maybe using unity built-in Tilemaps per chunk would be fine as well? I may be wrong, but I think they are building mesh under the hood as well, so it should be as good as building my own mesh? If someone got hands on this, can you confirm please?

Thank you!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Rhyusaky · Sep 15, 2020 at 02:22 AM

Yes you can use Unity tilemaps solution. It will work very fine for entire map loading too (but with some memory impact). The one of uniques drawbacks of this method is that Unity tilemaps doesn't have any mesh optimizations (like using quadtrees for lowering vertices count), but for the great majority of the cases, it will be very fine. Another advantaje of Unity tilemaps is the update velocity, if that was important for you.

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 cboxgo · Jan 25, 2021 at 10:16 PM 0
Share

How would you handle a map that's defined as 8000x8000 but only renders as 50x50 using Unity? The original question seems to indicate that the game would never allow more than 50x50 tiles to be seen on-screen. If you have a resource file that contained 8000x8000 tiles, how would you instantiate offscreen tiles to handle loading (as destroying) as the camera moves across the tilemap? I have yet to see any Unity tilemap examples for this scale, but I'm genuinely interested as is (or was) the poster.

avatar image Rhyusaky cboxgo · Jan 25, 2021 at 11:59 PM 0
Share

That's sounds not like an extremely difficult thing to do. In reallity, you can make a script that spawns tiles around player, like a chunk system, it will work very fine I guess.

And that will come with the little advantage of reducing the meshes size at memory in runtime.

avatar image cboxgo Rhyusaky · Jan 26, 2021 at 12:16 AM 0
Share

Creating a sprite instance in front of a player or behind a player is pretty easy. Destroying objects far away is easy too. But, it seems like it's a grey area in how tilemaps are managed... Does Unity automatically create and destroy objects off screen? I haven't seen anyone really touch on how the tilemap can be managed to prevent overuse of memory...

avatar image
0

Answer by KonjiaStudio · Feb 06 at 05:38 AM

Just save the chunk data (Terrain, Objects, Etc.) When they are out of view or chunk visible range. On the tilemap you can set the tile(s) to null when they're out of range and load them back in using the saved chunk data when in range. Using scriptable objects for the tiles works great because you're not allocating new memory for each tile, you are simply referencing the scriptable objects data. I used this method of rendering in an experimental tilemap world generation project I worked on in the past. I was having issues with blending tiles in a mesh, so I tried a simpler approach. It worked fine; it was even better with the unity 2D lighting system which was causing a major headache when having multiple tilemap layers. I hope I helped a bit.

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 KonjiaStudio · Feb 06 at 05:41 AM 0
Share

I also recommend you check out the 2DExtras package. The rule tiles work great with the terrain, walls or mountains (Like rimworld). You can plug rule tiles in as if they were normal tiles in Tilemap.SetTile(Vector3Int, Tile).

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

278 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 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 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 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 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

How to return tile based on heightmap efficiently? 0 Answers

Best way to make a big 2D map as smooth as possible? 1 Answer

How to assign individual data to a tiles? (Unity3D Tilemap) 0 Answers

Draw 2d map array with SetTile or Instantiate ? 0 Answers

How to add tilemap to procedural generation 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