Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 chillersanim · Jun 12, 2013 at 03:02 PM · instantiateframerate

Instantiate problem for game editor

God day.

I have a big problem with the instantiate frame drop. I'm working on a game editor in which the player can place as many objects as he want on a 2D grid. The problem is, after placing 50 or more objects, the frame rate begins to drop. So far as I understood, that drop is caused through the Instantiating of objects.

On the internet, I found a solution with an object pool, but the problem is, that I have a huge grid with 256 x 256 placing points, so that the player could place up to 65536 individual objects. When I consider that there are many different objects which can be placed, I would need an object pool, that contains 65536 x (placeable object count) objects at the start.

I already tested it with placing 65536 objects inside the unity editor. Thanks to dynamic batching, the framerate is stable.

My question at you is: Is there a way to add objects to the grid without frame drop and without overloading the RAM at the start?

Comment
Add comment · Show 5
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 MissingSemicolon · Jun 12, 2013 at 03:27 PM 0
Share

That's a lot of objects you are allowing players to create, what's the idea behind this game/application?

You might find there is another way to do what you want that avoids this problem.

avatar image chillersanim · Jun 12, 2013 at 03:37 PM 0
Share

Well that whole project is a maze game, in which you can create your own maze with predefined parts. Perhaps 256x256 is to big, but the problem is actually not the size, but that the framerate drops after only 50 placed object...

I'm actually trying with a object pool, but only with one object. This object gets edited (Replace mesh, meshrenderer and collision object) and then placed. I hope that that works better...

avatar image MissingSemicolon · Jun 12, 2013 at 03:48 PM 0
Share

Hopefully that will help!

As an alternative, how about letting the player 'draw' the maze they want rather than placing the objects themselves? so effectively let them draw lines that would represent a wall.

Then once it has finished you could have a 'Build!' button and it will build it (maybe behind some loading screen or something).

Is the frame rate drop due to the amount of objects on the screen or does it happen only when you instantiate each object? i.e. frame drops for a few seconds and then returns to normal.

avatar image chillersanim · Jun 12, 2013 at 06:47 PM 0
Share

The problem here is the same. The objects gets added at runtime, so it makes no different why and when they are added. Only exception, when you add them directly at the start of the game.

So far as I understood, the problem is only caused through adding objects during playtime. The adding process does something with the ram, that causes a longtime lag.

avatar image chillersanim · Jul 08, 2013 at 04:30 PM 0
Share

Smal update from me... After I tried many different ways to place objects during the game, I did not find anything.

What I have tried: - Instantiate empties at start() and give them all needed components, so that I later can easy replace the components of those empties. (To reserve ram space and prevent heavy ram management) - Instantiate finished objects to replace they'r mesh and components with the needed objects (same reason as above) - Directly place objects without object pool

All those ways didn't work, always I had the same behavior. After the first few placed objects, the cpu time starts to decrease, after ± 50 objects, the cpu time is at 0.2ms (before ±10.5ms)... It stays there for ever. If this is really a problem with the ram access from unity, then it i a bug. I have no other explanation. Short time drops can be possible, because of ram access, but not that long.

If somebody has an idea, what could be the problem, please post it, else I will send a bug report.

Greetings Chillersanim

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Veehmot · Jun 12, 2013 at 05:02 PM

A technique used in world editors is pretty similar to the way Google Maps works: you only store in memory the objects currently visible.

So imagine you want to scale your application to 1,024x1,024 = 1,048,576 objects. There's no way Unity (or other engine for that matter) will be able to handle that amount of objects.

The tricky partt is when you start at the zoom out level, because you need to show an overview of the map. For this you should store a low-resolution image of the map, generated either on loading time, or when you save the map back to disk.

There's no way an user can edit the map while at the zoom out level. Check for example Curiosity, which deals with billions of objects, and don't let you edit them at the zoom out level, only when you zoom in.

When you zoom in, what you need to do is serialize and destroy the objects not currently visible, so you can load them back later from disk. Pretty similar to the way any modern carthographic map viewer works.

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 chillersanim · Jun 12, 2013 at 06:50 PM 0
Share

Thanks, for bigger mazes would that be a possibility. But it isn't exactly the solution to my problem, because I've my problems with the instantiating of objects. The amount didn't affect the fps, I already tested it.

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

16 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

Related Questions

Lagspike when using instantiate in coorutine 0 Answers

Huge Framerate Drop 0 Answers

Checking if object intersects? 1 Answer

Performance issues with grid based terrain 2 Answers

How to improve performance with a lot of same prefab? 2 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