Stats greatly fluctuating. Do not know what is causing it.

So I am currently working on a group project in Unity 5. We are struggling with framerate issues at the moment. When taking a look at the stats they greatly fluctuate very rapidly. Examples of this is setpass calls changing between 80 and 6000, tris changing between 70 000 and 1,7 million and batches changing between 160 and 7500.

Below are two screen caps taken only a second apart (note the changes in the stats window): and

Can someone give some insight into what might be causing this behaviour ?

Time to learn how to use the profiler in 5.x.

I suggest you do the following steps:

  • If you have Unity pro, use the profiler to see what’s going on.
  • If not follow these steps:
  • Backup your project
  • Run the game in the editor and collapse all gameobjects in the hierarchy.
  • Start deleting the gameobjects one after another
  • See when it stops fluctuation.
  • Restart the game and only delete the object you deleted last
  • If the problem is gone, restart again, expand that object and delete it’s childs, one after another.
  • If it wasn’t solved by just deleting the last deleted top object, try to find out which top gameobjects has to be deleted together to solve the problem
  • If you get a NullReference exception after deleting an object, it’s the best time to insert some null-checks into those scripts ^^.
  • Once you have isolated the problem think about what scripts are attached to those object(s) and it’s childs. What do they do / change each frame. What other components are involved? Particlesystems, Rigidbodies, GUI, Renderer

Additionally you might want to press the pause button in the editor and step through your game (the button on the left of the pause button). Do you see any pattern? Switching each frame? About every X frames?