android - Constant and probably inaccurate Frame Rate -


i using following code calculate frame rate in unity3d 4.0. it's applied on ngui label.

void update () {         timeleft -= time.deltatime;         accum += time.timescale/time.deltatime;         ++frames;          // interval ended - update gui text , start new interval         if( timeleft <= 0.0 )         {             // display 2 fractional digits (f2 format)             float fps = accum/frames;             string format = system.string.format("{0:f2} fps",fps);             fpslabel.text = format;                 timeleft = updateinterval;                 accum = 0.0f;                 frames = 0;             }     } 

it working previously, or @ least seemed working.then having problem physics, changed fixed timestep 0.005 , max timestep 0.017 . yeah know it's low, game working fine on that.
problem above fps code returns 58.82 time. i've checked on separate devices (android). doesn't budge. thought might correct, when saw profiler, can see ups , downs there. it's fishy.

am doing wrong? copied code somewhere (must script wiki). there other way know correct fps?

by taking cues this questions, i've tried methods in first answer. following code returning constant 58.82 fps. it's happening in android device only. in editor can see fps difference.

float fps = 1.0f/time.deltatime;

so checked value of time.deltatime , it's 0.017 constant in device. how can possible :-/

it seems me fps counter correct , fps of 58.82 caused changes in physics time settings. physics engine cannot finish computation in available timestep (0.005, low), , means keep computing until reaches maximum timestep, in case 0.017. means frames take 0.017 plus other overhead rendering / scripts may have. , 1 / 0.017 equals 58.82.

maybe can fix problems have physics in other ways, without lowering fixed timestep much.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -