Hey Primus88,
The video was captured on my laptop. The lagging you see is a combination of things, including the video capture software, however, in the editor I mostly eliminated pauses. While the physics is an impact, on a game like this with so few actually moving pieces, i’ve found instantiating GameObjects and constantly running unnecessary code (like in Update() ) has a bigger impact.
I was seeing frame rate drop from 35-55 to at least half, often as low as 9 whenever the level initialization code ran. Fixing it was not too hard actually, I created a Tick class, that basically executes a local Tick method on an interval, moved the Update code to the overridden Tick method, then call the Ticker method in the class from Update. I set the ticking at 1 sec by default, and that alone seems to drastically lower the impact of the level manager (unlike input processing, most classes don’t need real time updating). Later I’ll play with the delay to see what I can get away with.
Then I moved all the level initialization code to a separate method, and run it in advance of the level being complete, preloading some arrays and fields. Then when I’m ready to start the level, I just copy the information to the actual runtime classes. For example, the ships are instantiated when the current level is 60% complete, then moved into a shufflebag for deployment just before level start (when the level text is displayed).
The net of just adjusting those two things is a constant frame rate of 44-64 on desktop.
As for mobile, well, I’m testing using a Galaxy tab 2 7", thus far I’ve seen little performance difference between desktop and tablet. I’ll need to try some lower end devices before go live. So long as I keep RAM usage and graphics fill rate to reasonable usage, then the gap between desktop and tablets (at least) is really minimal. My daughters Galaxy Note 8", with it’s quad core and 2 Gb of ram, will usually run these games faster than my 2 yr old stock Dell with dual core and 4 Gb of RAM.
Of course, if physics does get in the way, I can shift the ships from physics driven to transform based with a single prefab setting
(also auto converts the rigidbody to Kinematic, only the projectiles need be physics driven at that point. But… the ships don’t physically respond to damage the way they do now when I do that (mostly… actually they’ll auto drop into physics after their health reaches 0, so they drift/sink, but it’s still not as nice as the random tossing and rolling they do now )
Thanks for your feedback!
Cheers,
Galen