- Home /
Performance Problems - Object Quantity
I've been working with modular ships in a shmup, and am having substantial problems. I can have about ~20 modular ships (via many child objects for each ship) active and on screen, each with ~30 total objects, without performance problems. If I increase the object count to ~40 per ship, without adding any additional scripts at all, I get a slideshow.
Everything points to the pure object count. Nothing is being instantiated at the time, and none of my scripts search through the whole object database. The game uses only ~25% of my available memory during all of this. My GPU barely even notices the load from the simple meshes being used. The additional objects do add more box colliders (about two box colliders per three objects, on average), but no additional rigidbodies nor any additional scripts. Collision detection on each rigidbody is set to discrete. The game runs at 120 fps (including physics) and is smooth as butter otherwise.
What can I do to improve the situation, or at least get a better idea of what is going wrong?
Thanks,
How do your draw calls look? If you have Unity Pro, you can run the profiler to see what's up as well.
Unfortunately, I don't have Pro and don't have the logistics in position to purchase it. Believe me, I wish that I did!
In the Game view press the Stats button. Then take a screenshot of that and post it back into your question so we can see some numbers. Also, do you get any errors or warnings in the log? Sometimes when things go badly wrong the framerate can drop because your game is causing so many errors/warnings that time is burnt writing these to a log.
Your stats look excellent to me, except for obviously the 184.3ms frame time. It would appear that there is something in your code that is eating up a lot of time.
If you know for sure that is not the case, then possibly the problem is related to Device.present and the order in which graphics are updating/code is updating. Check out this link http://forum.unity3d.com/threads/86312-Device.Present-in-profiler....what-the-deal. Unfortunately, the easiest way to check if this is occurring it to see if the Device.Present function is showing up in the profiler. There is a setting mentioned in that thread that you might want to try turning off and see if you have any improvement.
I'm told that using the 'transform' automatic lookup can have performance penalties, as well- if you're going to be making a lot of calls to an object's transform, thing about keeping a reference to a Transform 'myTrans' which you assign in start, and from then on use that ins$$anonymous$$d of using the automatic lookup.
Your answer
Follow this Question
Related Questions
Counting active objects in a list 3 Answers
Attach Object to Object?-IS IT POSSIBLE? 1 Answer
Why do my objects keep changing speed? 1 Answer
Return a parent object to different derived objects from a function 2 Answers
PlayerPrefs on gameObject 1 Answer