Under 60 FPS and the game goes into Slowmo

The game I'm currently working on is having a very odd issue. If it doesn't run at exactly 60 fps or higher, it'll go into slow motion. I've tried switching up the time and physics settings, but I just can't find the cause. Does anyone know why this would happen?

Likely you have vsync turned on, this will cause it to run at 60 fps, or drop to 30 if you miss it by a frame or so.

Maybe you have the cause and effect reversed? Maybe something is happening that suddenly kills your framerate from 60 down to a much lower number.

Are you doing any of the game logic in Update? For example,

delay=delay-1; if(delay<0)... . If so, moving it to FixedUpdate should give a consistant speed, which is exactly what its for. Last I checked, FixedUpdate always runs at 50/sec, which should put you a little slower, but at least it won't bounce around, and you can tweak it back to where it was.

You'll want to change how you are handling the WaitForSeconds per your comment on owenpat's answer. Check here: http://unity3d.com/support/documentation/ScriptReference/WaitForSeconds.html. That actually waits for that amount of time. You want to do updates in the Update orFixedUpdate (for physics) and use deltaTime.

function Update() {
    // Move the object forward along its z axis 1 unit/second.
    transform.Translate(Vector3.forward * Time.deltaTime);

    // Move the object upward in world space 1 unit/second.
    transform.Translate(Vector3.up * Time.deltaTime, Space.World);
}

OR

function Update() {
    // Move the object forward along its z axis 1 unit/second.
    transform.Translate(0, 0, Time.deltaTime);

    // Move the object upward in world space 1 unit/second.
    transform.Translate(0, Time.deltaTime, 0, Space.World);
}

http://unity3d.com/support/documentation/ScriptReference/Transform.Translate.html

I think the `yield Wait(0.01f)` may be the problem -- I believe anything less than a 1 frame delay may just run on the next frame (my computer refuses to drop the frame rate, so can't test.)

Try dropping something with a rigidbody and see if it falls slower, or throw in a particle emmiter. If they aren't slower, then the slowdown really is in your code.

At any rate, using lots of very small waits, in general, tends not to be reliable. If you don't like drawcoder's response and really want yields, try something like (add a rigidbody with gravity turned off, don't need a collider):

transform.rigidbody.velocity.x = 5;
yield WaitForSeconds(2); // total of 10 moved
transform.rigidbody.velocity.x = 0;