1
\$\begingroup\$

Simple question, how do I limit the games fps in Unity?

I know there's Application.TargetFPS and whatnot, but it doesn't actually cap it. It just tries to get it.

Vsync also wouldn't work, because you should be able to cap fps without having to enable vsync, also if I use vsync I wouldn't be able to cap the fps to a custom value, say 23.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

It sounds like you have some sort of misunderstanding.

Application.targetFramerate sets the framerate that Unity tries to run at.

  • If the current device is not capable of running at the desired framerate, then the actual FPS will be lower.
  • If the device is more powerful than is needed to run at the desired FPS, Unity will attempt to limit the framerate to the target framerate (in other words, cap it). Depending on the device and how you're measuring the framerate, the framerate may sometimes fluctuate slightly higher than the target, but not by a significant amount.

Make sure you read the documentation thoroughly because there are several important quirks and differences between platforms.

So in summary, you can use Application.targetFramerate to cap the framerate, unless you're on one of the platforms where targetFramerate is ignored if you have Vsync enabled (in which case Vsync will cap the framerate). If you are seeing unexpected behavior, the first thing to check is whether there are any scripts that might be changing the target framerate.

I often use targetFramerate to cap the framerate in the Editor, so my GPU isn't running at max power at all times when Vsync is off.

\$\endgroup\$
1
  • \$\begingroup\$ interesting, last time i tried when setting target framerate to 60, it was at around 70. Perhaps ill try again. \$\endgroup\$
    – Pow
    Jan 27 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .