Not always going for the highest possible FPS.

edited in Questions and Answers
So here's an interesting thing that someone on the Desktop Dungeons forums threw at me today: They asked us to limit our FPS so that the game would be less taxing on lower end systems. Specifically citing the way Solitaire on laptops drops to 0 FPS when it's not doing any animations.<br><br>That lobbed a spanner in my brain.<br><br>It's definitely an interesting concept, I mean, before that point I was super stoked that DD was cranking out a solid framerate (it tends to be locked to 30/60 in browsers) from Unity, given all the crazy event logic going on in the background (never make a roguelike). I was stoked with a couple of rendering tweaks that gave us another couple of hundred FPS in standalone mode by reducing draw calls dramatically, but now I'm inverting my thinking...<br><br>Well, not inverting entirely. I still want as little time spent per frame, obviously, but now I'm thinking how I can make the game stop running like a greased whippet when it's not actively animating something. Lower end machines are definitely in our target market for the game, but previously I'd just assumed that because the game wasn't being super hardcore 3D (we do a couple thousand polys per scene, it's not rocket-surgery for onboard graphics cards) we'd naturally be a good fit for lower spec hardware. Seems there more I can do.<br><br>Any ideas on how to make rendering more event/message based in Unity? And/or any other ideas that might make limiting framerate a positive thing? I'm wondering if there might be gameplay relevance to framerate limiting, sorta like how the slowdown from drawing hundreds of bullets in arcade shooters would tax their boards and give players extra time to plan their dodges - it started out as an unintended side effect and became a sort of bullet time that the designers would push for - some even built super-hard bosses that DIDN'T spam bullets so that you had to beat them at full speed. Hah!<br>

Comments

  • You should be able to just set <a href="http://unity3d.com/support/documentation/ScriptReference/Application-targetFrameRate.html">Application.targetFrameRate</a> = 30; to clamp tot 30fps on all devices. Then Unity should be sleeping the CPU to make the sync time, thereby not taxing the CPU nearly as much. This is especially useful for saving battery drain on mobile devices.<div><br></div><div>I haven't done it myself, but theoretically you could change that value on the fly, and lower it down to 5 or something when the app is out of focus, or if it hasn't received input for a certain period of time as well; then bring it back up again once it needs to take full input again.</div>
  • Flash uses this exact strategy to save CPU usage as well...<br>
  • @AngryMoose Aha! Thanks :) I'll investigate Application.targetFrameRate once we hit this week's bug-fixing days. It'd be nice if the dynamic setting was an easy way to give people more performance on the fly as well - definitely a lot less hassle from my side.<br>
  • Note, and please check me up on this, but I believe <span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; text-align: left; background-color: rgb(255, 255, 255); ">Application.targetFrameRate does not work in the editor. It's only for builds.</span><div><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; text-align: left; background-color: rgb(255, 255, 255); "><br></span></div><div><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; text-align: left; background-color: rgb(255, 255, 255); ">Also, if you want to limit to 30 fps specifically, you can set your quality settings vSyncCount to 2. I believe with script you can do it like so Quality.vSyncCount = 2</span></div>
  • <i style="font-family: Arial, Verdana; line-height: normal; "><span style="background-color: rgb(204, 204, 204);"><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; text-align: left; ">"Note, and please check me up on this, but I believe </span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; vertical-align: baseline; line-height: 18px; text-align: left; ">Application.targetFrameRate does not work in the editor. It's only for builds."</span></span></i><div style="font-weight: normal; font-family: Arial, Verdana; line-height: normal; "><i><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; vertical-align: baseline; line-height: 18px; text-align: left; background-color: rgb(255, 255, 255); "><br></span></i></div><div style="font-weight: normal; text-align: left; "><font face="lucida grande, Lucida Sans Unicode, tahoma, sans-serif"><span style="line-height: 18px;">That was the case in older versions of Unity, but it works in the Editor now as well.</span></font></div><div style="font-weight: normal; text-align: left; "><font face="lucida grande, Lucida Sans Unicode, tahoma, sans-serif"><span style="line-height: 18px;"><br></span></font></div><div style="font-weight: normal; text-align: left; "><font face="lucida grande, Lucida Sans Unicode, tahoma, sans-serif"><span style="line-height: 18px;"><br></span></font></div><div style="text-align: left; "><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; background-color: rgb(204, 204, 204);"><i>"Also, if you want to limit to 30 fps specifically, you can set your quality settings vSyncCount to 2. I believe with script you can do it like so Quality.vSyncCount = 2"</i></span></div><div style="font-weight: normal; text-align: left; "><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; background-color: rgb(255, 255, 255); "><i><br></i></span></div><div style="font-weight: normal; text-align: left; "><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; background-color: rgb(255, 255, 255); ">Not necessarily. Using the vSyncCount ties you into the refresh rate of the display, so if you are on PC and your monitor is running at 70Hz, you're not going to be clamping to 30fps by syncing to every second refresh :)</span></div><div style="font-weight: normal; text-align: left; "><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; background-color: rgb(255, 255, 255); "><br></span></div><div style="font-weight: normal; text-align: left; "><span style="font-family: 'lucida grande', 'Lucida Sans Unicode', tahoma, sans-serif; line-height: 18px; background-color: rgb(255, 255, 255); ">ps. Is there a "quote" link that I'm just missing or is that not supported on these boards atm? :P</span></div>
  • The quoting system isn't in place yet, I'm looking at a temporary solution while waiting for the next Vanilla release.<br>
  • @AngryMoose, ah, thank you :) Learn something new every day. What you say makes sense. 
  • Haven't had a chance to mess with Application.targetFrameRate yet, I'm busy hunting down a memory leak that's slowly strangling really long runs of the same dungeon. Sigh.<br>
  • Aren't you coding in C#? Is a memory leak even possible in C#? If so, how? I thought the GC should take care of it.
  • It's possible to leak memory whenever you allocate outside the managed pool that C# (actually Mono, if you're using Unity) has the GC handling. This happens when you create render to texture memory surfaces - C# doesn't know anything about graphics memory in that case, so you have to be sure that you're freeing it correctly when you're done with your texture.<br><br>There's also more mundane stuff: Creating objects dynamically in Unity and then losing references to them. They'll sit there, updating and not actually participating in the gameplay at all, but eventually you run out of memory in the browser environment and crash.<br>
Sign In or Register to comment.