Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
  • Help Room /
avatar image
0
Question by MKayJay · Dec 26, 2021 at 02:02 PM · procedural generationobject pool

How should I go about handling the performance impact from 50.000ish gameobjects in my scene?

Hello, I'm currently working on a prototype for an FPS survival/base defense game. In my current stage of development, my main focus is world generation. Without going too deep into the premise, I basically randomly generate a finite world (But can be quite big), with randomly placed things like trees, stones, ores, and more. Additionally the player will place objects (Which over time can amount to hundreds or even thousands, for really long plays).

(Picture, just for reference.. and to make this post a bit colorful :P ) alt text Although all these objects are not really doing anything (They can be harvested/mined), I cannot make them static, as they will be manipulated/animated when interacted with.
Currently, I have around 15.000 gameobjects in a scene at one time, which for my mid-end PC, runs smoothly.
Upon testing with around 50.000 gameobjects, this is where I start to feel it and end up around 25-30 fps. (Should be mentioned, this is by running it in the editor)

I've not had too much need for object pooling before, but I am considering if I should move in that direction?
Basically, I have two thoughts, Either I make some object pooling system, where I keep x amount of each object in memory, and move them in view of the player, when applicable.
Alternatively, I've considered just spawning in all the objects, and simply disabling/enabling them at runtime, again based on the view of the player.

I'm basically just asking here to get some thoughts on this.
Does any of you have any input/experience with either approach?
Is there an angle here that I'm missing, which I should look into instead?

In any event, thanks for taking your time to read this :-)

postpic.jpg (492.7 kB)
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
Best Answer

Answer by Mikael-H · Jan 03 at 10:19 AM

I would evaluate if all your objects really need to be game objects. Could they live in a data structure and then be spawned as a game object when the player is near them?

If you have a tree, consider what data is needed to describe it. World coordinates, tree type etc. When the player comes near, instantiate a game object with scripts to update or use the data. When the player is not near, unspawn (and maybe put in a pool).

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 MKayJay · Jan 03 at 04:28 PM 0
Share

This is kinda what I had in $$anonymous$$d myself. I would think that a pool is probably necessary, as instantiating and destroying objects will likely be taxing at times when the player moves in and/or out of areas where there are a dense amount of objects. As for what to save, I would only need to keep track of Position, rotation, and scale, as well as the type of 'resource' and the amount of hp it has left.

I'm actually quite surprised that there are no options to at least disable gameobjects that are being culled. I know you may not always want that, but it would be awesome to you could toggle, or something.,, Maybe there's some other kind of overhead in that?

Anyways, just me going off on a tangent - Thanks for the input.

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

175 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

Related Questions

InvalidOperationException: Operation is not valid due to the current state of the object 1 Answer

procedural dungeon generator broken room placement. 0 Answers

why does my script not work even though I followed a tutorial? 0 Answers

Performance-increase/loading-time problem [object pool] 0 Answers

really big newbie need some advice/help! 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