FPS count is going less than 20 by increasing the number of 2D sprites
Hi, In our game we have the following game objects and the game objects count will increase with game play. 1. 4 game objects with box collider and each having a 2d sprite as a child to create lines 2. 4 game objects with sphere collider and each having a 2d sprite as a child to create a circle 3. 4 game objects with mesh collider and each having a 2d sprite as a child to create respective shapes
As i told game objects count will increase with the game play, becomes more sprites, leads to decrease in fps.
I am enabling and disabling the gameobjects based on whether gameobjects is on srceen or not but still i am facing the same problem.
Here i have attached an screenshot of the game for further details.
Please help me out in this, any help is appreciated.
Answer by Kastenessen · Jul 17, 2016 at 02:12 PM
It would be the amount of colliders and the physics processing maybe.
Do they have all rigidbodies and are they static or dynamic rigidbodies? If you are creating dynamically then make sure they are not static, as it will slow things down heaps.
Otherwise maybe look at writing the code to join verticies together to make less colliders, and reuse the same images or sprites as much as possible.
I can get some 650,000 sprites and still have 70fps+, so look into your colliders and whether or not they are static or dynamic.
Yeah other wise you will need to find ways of loading and unloading things that are off camera maybe.
Hope this helps.
Thank you for the valuable response.
Here all are static rigidbodies and colliders are also static. And i am doing loading and unloading the gameobjects based camera viewport. I am also doing object pooling.
Any suggestions from your side ?
Using statics will slow it down, mark everything as non static (dynamic).
That is if you are creating and destroying stuff.
Check your profiler just before its peak spikes and if it is a physics processing problem then it will show up there, you can check the call count for each script or object too, and find out what's going on like that.
Hope it helps.
Oh, make sure no colliders or sprites are overlapping too, cause that will make the physics processing and batching go a bit nutty lol.
Thank you,
I ll just go through your suggestions and update the same.
Yes, collider was the problem. Now it is working great.
Thank you $$anonymous$$astenessen.
You are most welcome, glad to have helped.
Please accept my answer if you like.
Your answer
Follow this Question
Related Questions
Running While Mid Air Problem 0 Answers
¿Cómo modifico Max forward speed en Unity 5.2.3? | How do I change Max forward speed in Unity 5.2.3? 1 Answer
What is the standard direction of a character relative to its own axis? 1 Answer
FristPerson Problem 0 Answers
What do I need to do to develop an FPS survival game? 1 Answer