My game has 10 same type of objects. previously i was doing wrong that was enabling and disabling gameobjects by destroy() and instantiate() methods. This was also hiccups my game for too long time. so I searched game optimization and found that these methods are the reason. so I found solution that is to use of SetActive() function. But also this method hiccups my game too. My Game only hiccups when I activate 10 objects simultaneously by this ganeobject.setActive(true) method. I have created one parent object and all these 10 objects are its child objects. so here is one of the portion of my script.
by making public Gameobject pins1, pins2, I assign that parent gameobject from inspector. so it will enable and disbale its 10 child objects. But that hiccups the game everytime when I enable and disbable this objects. Can anyone suggest what is the sollution of this hiccups? As I’ve said, it hiccups only the time when these gameobjects are activated. Any suggestion/solutions appreciated.
It could just be that your pins are too complex of objects. Depending on how often their active state is changed, you will always notice lag. Also, if many instances of the script are affecting many pins, you may want to stagger the setActive events so it does not all execute at the same time. If collision/physics does not matter, disabling the renderers only should not cause a hiccup.
I solved it by myself… but thanks guys for your suggestion. the original problem for hiccups was by the mesh of the gamebject. my children gameobjects have mesh of 3138 vertices and 6272 triangles. so I was instantiating those 10 objects simultaneously and that causes the problem. So i edited that gameobject in blender and by the blender s/w, I reduced the number of vertices and triangles to 1386, 1588 respectively. That makes the run without hiccups !