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 David_Simoniants · Apr 01, 2018 at 09:10 AM · gameobjectsperformance optimizationgenerationworldmany

Optimize performance of simple survival game

I am creating mobile survival top down 2d game. All renderers are sprite renderers, all colliders are box or capsule colliders. I wanted the world to be infinite, so I made world generating algorithm. Algorithm doesn't work slowly, but I notice that when number of generated gameobjects is more than 1000, the game starts lagging. The fps decreases from 120 to 0. I made algorithm that disables renderers and colliders (but not scripts) which are not in camera field of view. Didn't work. I disabled all gameobjects and it also didn't increase fps. The only thing that made fps higher is destroying all gameobjects. But I can't even disable them cause they have scripts that should always work. Scripts are simple, the maximum thing they do is counting time so they can't be the cause of lagging. How can I improve performance without destroying objects? Sorry, If I made mistakes in my English.

Comment
Add comment · Show 3
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 meat5000 ♦ · Apr 01, 2018 at 01:14 PM 0
Share

Did you test this in a build? If you are working from Editor on this issue you must realise that the Scene Camera also adds in to your total FPS and overall performance. To test this, in scene view, rotate the camera to the sky so it sees no objects and observe FPS.

avatar image David_Simoniants meat5000 ♦ · Apr 01, 2018 at 01:24 PM 0
Share

Nothing changed. I think that the problem is the algorithm that disables rends and colls of far located gameobjects.

avatar image meat5000 ♦ David_Simoniants · Apr 01, 2018 at 01:29 PM 0
Share

Ok, what does your profiler say? Its a shame, this wouldve been convenient :P

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MadsWiering · Apr 01, 2018 at 10:49 AM

Maybe take a look at object pooling, which holds objects in memory with a fixed size, you reuse these when you travel along the world. Objects you passed get set to a location you still have to travel to use. This makes your memory consumption consistent.

And I hope you are using 2D Colliders instead of the 3D , since you said capsule collider.

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 David_Simoniants · Apr 01, 2018 at 01:10 PM 0
Share

Really (if you mean that the algorithm that disables far located objects is the main cause of low fps), I tried to disable that algorithm and fps got higher to 100 and started hesitating between 60 and 100 fps. Is enabling/disabling renderers and colliders of gameobject and changing its layer takes enough much time to make FPS lower? Note: I am using 3D colliders for several reasons.

avatar image meat5000 ♦ David_Simoniants · Apr 01, 2018 at 01:29 PM 0
Share

You should not mix 2D and 3D. If you want to use 3D in your 2D game you should make it Psuedo 2.5D and not use the 2D features.

avatar image David_Simoniants meat5000 ♦ · Apr 01, 2018 at 02:21 PM 0
Share

I use 3D colliders cause I can pull them among z axis so that z values of positions of objects can be different and 2D colliders will pass through each other. Their z values are different cause game is top down and z=-y to sort objects without using Sorting layers cause they're limited.

Show more comments

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

79 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

Related Questions

How to create a simple world generator in Unity3D? 1 Answer

What's the best way of handling hundreds of objects in an infinite world without killing the framerate? 1 Answer

Create custom objects like in paper.io 2 at runtime 1 Answer

How to implement UVs with a triangular procedural mesh (1 vertex has multiple faces) 0 Answers

Loading many gameObjects 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