Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Zealord · Aug 03, 2015 at 05:31 PM · 2dgridtilechunksunload

What to do with "unloaded" gameObjects?

I'm working on a small 2D project that has a character moving around in a grid of tiles in a top-down fashion. I'm using chunks to reduce the processing load because it freezes a lot when generating large worlds and it worked; I have set up those chunks (GameObjects with tiles as children) with their data about held tiles (GameObjects with a Sprite Renderer and attached script) and they are managed in Lists by a world manager. I understand how to load the chunks near the player and all, but my question is:

When my character is somewhere in the game, and he has chunks loaded, what do I programmatically do with chunks that shouldn't be loaded anymore, for example the player moves away? They get removed my List of active chunks but where should I let them "go" to "unload" them.

I was thinking of disabling the GameObject of that chunk, and re-enabling it when the player is near but other than that I have no idea. My goal here is to optimize performance and unload unused chunks with their data for my to be large game world.

Maybe I'm missing something very important here but I just can't seem to wrap my head around a way of doing this.

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
0

Answer by TimHeijden · Aug 04, 2015 at 01:19 AM

It sounds like you're on the right track. What you are describing is almost exactly the same as pooling objects. There are a lot of posts, blogs, videos about it all over the interwebs :)

With object pooling, you create an initial amount of objects and use those throughout your game without having to create/destroy (load/unload) them all the time. Instead, you set the values of the objects whenever they are enabled or disabled.

Here is a non-descriptive but visual example of some dude who did something like this: http://jessefreeman.com/dev-diary/tile-map-editor-object-pooling/ Note the bottom GIF, where you see the tiles on the left get "disabled" and "enabled" on the right.

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 Zealord · Aug 05, 2015 at 09:07 PM 0
Share

That sounds like a good way, but it wouldn't be feasible with a generated terrain, there aren't a lot of "same" gameobjects in that aspect.

I searched a little more and found that I can serialize the tiles held by the chunk, and load them when they need to, but I'm worried about making loads of I/O operations on the disk..

avatar image TimHeijden · Aug 05, 2015 at 09:33 PM 0
Share

You'll have to rework what you have to work as if they are the "same" gameobjects. I don't have details on your current implementations & what the tiles should be doing, but it's pretty much always the way to go.

Like you said, the alternative would be doing lots of loading / unloading of gameObjects but that kills your performance...

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Grid Movement VS Free Movement 1 Answer

Unity 2D tiles and grid 1 Answer

2D Tile Map Question 0 Answers

I need to instantiate a bunch of objects without performance dips 1 Answer

How to use the same tilemaps among multiple scenes (e.g. making it a prefab)? 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