- Home /
What is causing a single hiccup at start of IOS game?
Once I launch the game and choose start from the menu the game runs fine until the 4th bullet is shoot(side scrolling shooter) or the 3rd or 4th collision(with my shooter and enemies but not the ground). At that point the game hiccups(freezes for 1sec). After this point the game runs perfectly and I can also reload the level with "Application.LoadLevel()" with no hiccups. To cause the hiccup again I need to exit the app and reopen it.
As my game is a side scroller I have enemies instantiated from the right(moving left) and the bullets are instantiated from the shooter(ship in my case) moving right. The ship can move in all directions but only shoot right.
Some notes
All enemies and ground have/has 2d box colliders
The bullet also has a collider, but also has a rigidbody
The shooter(ship) also has a collider and rigidbody
I do not have any objects instantiated at start()
This does not happen on android or in unity
I have tested iOS 8.1, iOS 7 including iPad, iPhone 5 and iPhone 4S all giving the same results.
Thank you for your help I will provide more information as needed and update if I myself find a solution. Thanks again.
Answer by g8minhquan · Dec 04, 2014 at 08:48 AM
In my experience, GameCenter, Facebook SDK, Google Analytics, Ad Mob,... (or other 3rd party library that use the internet) can be the reason. You can run the game through Xcode and monitor what exactly causes the hiccup.
I do have GameCenter in my game I will try and remove it and see if that works, but I have tested disabling the Internet which still gives the hiccup. Could you please explain what Xcode would say at a hiccup as I'm new to Xcode.
Removing GameCenter makes game hiccup at the 8th bullet.
After I add GameCenter back it seems to still hiccup at the 8th bullet, but I did remove all the Debug.Log(). I also don't see any feedback in Xcode but Xcode also hiccups at that point(cpu monitor, fps monitor etc hiccup). I have also tried 60fps I did get an initial freeze that required a restart but after that it does the same thing(hiccup then run normally).
I can somehow shift the hiccup position, by rebuilding removing objects. But I'm still not sure what is causing it.
If it happens at the exact moment (8th bullet fired), and the hiccup is really 1s long (yeah that's too long to be acceptable), then I believe the problem is somewhere in your code. Do you use Object Pooling for your bullet / bullet explosion effect?
Anyway, try print Debug.Log everywhere that you think can be the cause. Also use profiler and try to find what can be the cause. Instantiating large and complex prefabs can also be a reason, so check for that as well