Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm running into a situation where my frame rate drops from 70 FPS (on my desktop computer) down to 5 FPS (on my iphone) and I'm trying to understand why. At the moment, I'm only drawing simple tiles, with box colliders attached to them, on the screen...

enter image description here

I've read that colliders are very expensive to have and I have 2400 of them on the screen at any given time. My questions are...

  1. Do you think it's the number of colliders that are causing the slowdown?
  2. If so, what are some ways I can optimize this?
  3. If not, what do you think the problem is?

Thanks so much for your wisdom!

Also, it's worth noting that I'm using 2D Toolkit in Unity for drawing.

UPDATE: I just removed all the colliders in the scene and I'm still experiencing the slowdown. Your thoughts?

share|improve this question
3  
1. yes, 2. don't have so many colliders, Are you trying to achieve something in particular? Also note not a good measurement between desktop and phone (different systems), if you wish to benchmark start of with no colliders and add more till 2400 to compare the equiv speed differences. –  AbstractChaos Aug 8 '12 at 17:24
    
ok, so it's actually not the colliders. I just removed all the colliders and the i'm still experiencing the slowdown. Your thoughts? –  BeachRunnerJoe Aug 8 '12 at 18:00
    
Removing the colliders will make performance worse right? I mean your intent is to optimize collision...or what? Have you considered checking the settings for your iphone project? –  Sidar Aug 8 '12 at 19:19
    
When exactly do you experience the slowdown, please describe your setup. –  jonas Aug 9 '12 at 7:56

2 Answers 2

Any time slowdown is an issue, the important thing to do is test and measure. There are a variety of tools available to do so, but even without a profiler you can do this simply by measuring the time different sections take via things like System.Diagnostics.Stopwatch (if using C#) or even the base unity Time information.

You've already determined the colliders, while very numerous, don't seem to be the cause of the performance drop between systems so see if you can rule out other large sections of your code, either by timing or by simply commenting them out and testing framerate again. Chances are you'll find a big chunk somewhere that suddenly brings the framerate up when you leave it out and you can then repeat the process inside that chunk until you've found the offending section.

share|improve this answer
    
good tips, thank you! –  BeachRunnerJoe Aug 8 '12 at 18:49

I'm new to this, but it would seem to me that if things aren't working, you should try something else. So maybe try a fewer colliders?

EDIT: You also might try using a fixed frame rate, like described here: http://obviam.net/index.php/the-android-game-loop/ Maybe you can fix the framerate so it stays high

EDIT2: Maybe you have a memory leak? This article talks about that possibility on iOS: http://www.cocos2d-iphone.org/forum/topic/6641

share|improve this answer
3  
Good answers get upvotes. Not answers that ask for upvotes. This doesn't address the original question very well and it doesn't address the updated question at all (which was updated before you answered) –  Byte56 Aug 8 '12 at 18:17
1  
oh, thanks for the info - I'm pretty new to this, I'll try to do a better answer with my next one –  Bob Flanderson Aug 8 '12 at 18:18
1  
Bob, you can edit this answer to improve it, no need to wait until the next one. Additionally, you're free to ask a question before getting 10 points. You'll just have to make it simple without all the images and links you want. If it's a good question it'll get upvoted and you'll have enough rep to update it with images and links. –  Byte56 Aug 8 '12 at 18:20
1  
Oh, ok - I've been trying to help people out with their questions by trying to find good resources for them online. Thanks for the tip! –  Bob Flanderson Aug 8 '12 at 18:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.