Hola dragons and unicorns!
I want to create a offline demo (exe/mac) of our iPhone game “Pep the dragon ”. The windows-standalone runs with something like 300fps, so is there a way to limit Unity/ Standalone itself to something fixed - a.e. 40 fps max ?
muchas gracias,
pep el dragon
Dunno where I got it from, but that works.
using UnityEngine;
using System.Collections;
using System.Threading;
public class fpslimiter : MonoBehaviour {
float oldTime = 0.0F;
float theDeltaTime= 0.0F;
float curTime= 0.0F;
float timeTaken = 0.0F;
public int frameRate = 120;
// Use this for initialization
void Start () {
theDeltaTime = (1.0F /frameRate);
oldTime = Time.realtimeSinceStartup;
}
// Update is called once per frame
void LateUpdate () {
curTime = Time.realtimeSinceStartup;
timeTaken = (curTime - oldTime);
if(timeTaken < theDeltaTime){
Thread.Sleep((int)(1000*(theDeltaTime - timeTaken)));
}
oldTime = Time.realtimeSinceStartup;
}
}
Eric5h5
September 9, 2010, 9:05pm
3
Use Application.targetFrameRate.
That’s outdated, from the days before targetFrameRate existed.
–Eric
Hi Eric, have a question for you, doing that do I cause a fissure in performance in any way?