Rotation Framerate Independent

I am trying to get a rotation to be framerate independent and for some reason this is not working. This object is supposed to move from position to position with Lerp, which is working correctly, while the texture rotates in the Z, like a razor. The issue is that the razor is spinning at the correct speed on PC/Mac, but on Ipad3 it is much slower. I tried using both Update and Fixed Update, same result. I have this working with other objects that do not use a rigidbody, I am not sure if that has anything to do with it or not. It has a rigidbody because it hits triggers that enable the lerp to go back and forth. The object is a prefab that has a collider and texture as children, I have pics below of the exact construction, it is called SmallRazor, and my code, any help would be appreciated I have been stuck on this for hours lol.

1407418--73344--$2.png

var pos1 		 : Transform;
var pos2 		 : Transform;
var startState	 : boolean;
var s2   		 : boolean;
private var rotateSpeed  : float = -250.0;

function Update ()
{
transform.Rotate(0, 0, rotateSpeed * Time.deltaTime);  /// This is the Rotate

if (startState == true)
	{
	transform.position = Vector3.Lerp(transform.position, pos2.position, Time.deltaTime * .3);
	}
if (s2 == true)
	{
	transform.position = Vector3.Lerp(transform.position, pos1.position, Time.deltaTime * .3);
	}
}

// TriggerEnter
function OnTriggerEnter (other : Collider)
{
if (other.gameObject.tag == "RazorStart")			    
{
	startState = true;
	s2 = false;
}
if (other.gameObject.tag == "RazorEnd")			    
{
	startState = false;
	s2 = true;
}
// Player
if (other.gameObject.tag == "Player")			    
{
 InvokeRepeating("ConanDamage", .1, .6);
}
}

I tried a bunch of different things, including removing components, removing the lerp from the code, etc. It seems that transform.Rotate is not working with Time.deltaTime correctly. Does transform.Rotate not work with Time.deltaTime the same way that transform.Translate does?

I would also like to add that on the ipad it is very slowly rotating in the BACKWARDS direction of the way it is very fastly rotating in the PC build. Stumped!

Is it actually rotating slowly in the wrong direction, or are you simply seeing an equivalent of the Wagon-wheel effect?

If you try a [much] lower rotational velocity, what happens?

Yes! The wagon effect is what is happening. That is strange that the PC doesn’t have the same effect. And for some reason I can’t achieve the same fast looking rotation on the Ipad because it starts doing the wagon effect, but I can get it close enough. Thanks for that suggestion very much. Any idea why the PC/Mac version wouldn’t have the same effect?

Best guess would be framerate differences. On PC/Mac, you’re most likely running with vsync off, so you’d be rocking a higher framerate than on an iDevice (which is vsync’d to 30/60 fps). Lower framerate means bigger jumps per frame, and if that jump happens to “fight” the art, then the wagon-wheel effect will be much more noticeable (eg. you have teeth 5 degrees apart, and each frame rotates 4 degrees, you might tend to see a 1 degree/sec backwards rotation).

Typically if you need a really fast rotation, it can pay to swap textures/assets by rotational velocity. Good example would be rotor blades on helicopters, which might swap the individual blade mesh asset with, say, a radially-blurred disc once the rotational velocity is high enough.

Thank you for the detailed response, great info. So when I use Time.deltaTime to make things frame independent, it really only goes so far huh?

Well when things are referred to as framerate-independent, this typically refers to gameplay considerations, rather than visuals. Making player movement, for example, framerate-independent just means that the engine keeps your player moving at, eg. 60 meters per second, rather than 1 meter per frame. The former means that no matter the framerate, your player is still moving at a predictable rate, while the latter means that it will move faster or slower depending on framerate (which is typically a bad thing).

The disk is rotating at the correct speed, and it is rotating in a frame-rate independent speed. Specifically, it is rotating by 250 degrees per second. I would anticipate, if you added an arrow to the texture, similar to some clock hands at 12 o’clock, you’d then see the disk spinning exactly as you’d expect. Because the detail on the disk is very very small, I suspect that the eye is attempting to make sense of the rotation, and is assuming that the teeth are moving a small distance, so it looks like it’s rotating slowly. Some clock hands would obliterate this allusion.

1 Like

Thanks for all of the help guys, I really appreciate it.