x


How to set FixedTimestep to give exactly 60 steps per second instead of the default 50

Please correct me if I'm wrong in this paragraph - the maximum FPS you'll get from a game depends of FixedTimestep. If your CPU calculates each frame in time, you get the maximum FPS (assuming you got the best graphics card in the world and it always draws on time), if it doesn't, you'll get an actual game slowdown opposed to a visual lag caused by a possible bad graphics card.

The FixedTimestep of a project is by default set to 0.02 which gives 50 expected frames per second. I want 60 frames per second like games usually have, but for that I'd have to set it to 0,0166666666... So the value will get clamped. What should I do here? Once I set a FixedTimestep value and accept it, there's no turning back, because I'm doing a lot of things dependent of Time.deltaTime, and I don't want them to speed up or slow down as I change FixedTimestep (If there's a way to avoid that too, how do I do it without messing with TimeScale?)

more ▼

asked Jan 21 '10 at 11:28 PM

Micha Lewtak gravatar image

Micha Lewtak
130 7 7 10

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

The fixed timestep is for physics. Do everything in coroutines or Update, and do nothing in FixedUpdate except physics calculations. The only reason to change the fixed timestep from the default .02 is if you want the physics engine to run more or less often than 50 fps. The framerate of your game is "as fast as possible" normally, with the following exceptions: 1) vsync is on, in which case the framerate is limited by how fast the monitor refreshes, or 2) you set Application.targetFrameRate to something greater than 0, in which case the framerate will (more or less) not exceed that value.

more ▼

answered Jan 22 '10 at 12:24 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

So if I'm making my own physics script, I should put its code in fixedUpdate() and use Time.fixedDeltaTime instead of Time.deltaTime for the physic-dependant object movement, right? While the rest of timed things like counters should always be multiplied by Time.deltaTime?

Jan 22 '10 at 07:02 AM Micha Lewtak

You should continue to use Time.deltaTime, actually. In a FixedUpdate function it will still give you the correct time delta.

Jan 24 '10 at 05:30 PM Eric5h5
(comments are locked)
10|3000 characters needed characters left

FixedTimestep only applies for the rate FixedUpdate() is called. I think the normal update is called as often as possible (depending on cpu). If you are using Time.deltaTime for all you movement you should be fine.

The FPS does not depend on FixedTimestep.

more ▼

answered Jan 21 '10 at 11:37 PM

StephanK gravatar image

StephanK
6k 39 53 93

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x572

asked: Jan 21 '10 at 11:28 PM

Seen: 2290 times

Last Updated: Jan 21 '10 at 11:28 PM