I’m making a 2d game for ios using unity. While making the game I began having an issue with lag, and I thought it was because I was using a lot of create/destroy functions, but after making a gameobject pool I was disappointed to see the lag still there. I have searched for hours and can’t fix it. The unusual thing about it is that after restarting the scene 3 or 4 times the lag is completely gone. I have about a total of 800 lines of code, I’m not using instantiate, destroy, or any kind of find functions, and there are about 20 objects active at any time.
Thanks in advance.
You can also use Xcode’s profiler to have a chance of playing “CSI” without a Pro license. I had similar issue, and, in my case Xcode’s Instruments told me the problem was CPU-based and resides in a labyrinthian path that seems to be related to physics (BTW, I also had my quota of flyweight components). The problem, after a long session of “RTFM”, was my dumb idea of using “rigidbody.transform.position += delta” instead of forces or non-rigid colliders.