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
1
Question by Andrisb · Aug 26, 2015 at 12:39 PM · optimizationgameobjects

How to optimize usage of many GameObjects?

I am creating a game in which player have to interact with many gameobjects (Mushrooms, trees, rocks, even tufts of grass). There is no problems with rendering, because i use layerCullDistances, but there is still many gameobjects. Maybe i have to save all gameobject positions in List and instantiate them when player are near? Or is there other way to do this?

Comment
Add comment · Show 1
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 cjdev · Aug 26, 2015 at 09:01 PM 0
Share

I'm not sure how your game is set up, but you could try disabling them when they're a certain distance from the player.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by axldoyle · Aug 27, 2015 at 09:37 AM

If I'm understanding your question something along the lines of object pooling could be helpful. This allows you to create lists of objects that can be actived/deactived on demand, it also has less of an impact than instantiating and destroying obejcts.... link text

Comment
Add comment · 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
0

Answer by Ches81 · Aug 28, 2015 at 02:38 PM

Instantiating objects while the user is playing is not a good idea, especially if there are alot of them. The allocation and deallocation of memory can cause hiccups while playing since the garbage collector has to kick in more frequently. A good way to avoid this problem is to use pooling, like axldoyle said. I recently wrote an blog article about that topic. Maybe this can help you finding a solution. http://blog.christianhenschel.com/2015/08/28/pooling-part-1-optimize-your-game-performance/#more-274

Comment
Add comment · Show 4 · 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 Andrisb · Aug 28, 2015 at 04:18 PM 0
Share

But if i have about 10000 gameobjects?

avatar image Ches81 · Aug 28, 2015 at 04:26 PM 0
Share

At once needed in the scene? I don't think so. Pooling is not just activate and deactivate GameObjects in the scene. If you use pooling, you create only a bunch of objects and reuse them. If an object isn't needed anymore you put it back into the pool until it is used on a different location. Everytime you pull an object out of the pool you have to set it's position, rotation etc. to the currently needed position/rotation.

avatar image Andrisb · Aug 28, 2015 at 04:41 PM 0
Share

In my scene there are trees, stones and other gameobjects, that have their positions. And i always need them (until they are far away from player).

avatar image Ches81 · Aug 28, 2015 at 05:10 PM 0
Share

Wow ok, that's a lot of stuff. But you don't seem to have any problems with your application's performance, so why you bother?^^

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I get the transforms of all the objects in my scene ? 2 Answers

Batching objects with Instantiate for optimization 2 Answers

DDMS error code.PVRSRVAllocDeviceMem. android game, Crashed. 0 Answers

Loading many gameObjects 1 Answer

Don't update gameObjects too away from player. 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