Different 2D physics behaviour out of editor? Webplayer bug?

Update: I think this might be a webplayer issue, because in standalone it works at normal speeds. In fact it seems to only happen in some machines. I had a friend test it and in his webplayer ran ok and the deltaTime and fps where the same as mine… Is my webplayer possessed? Tried reinstalling it to no avail.

Hi, I want to make some framerate independent movement code using 2D physics for a rotating sprite, but I think I might be missing something because when I test it in the web player it runs a lot faster than in the editor.

This is the code:

function FixedUpdate(){
	rigidbody2D.AddForce(new Vector2(moveHorizontal*100*Time.deltaTime,0));
	rigidbody2D.AddTorque(-moveHorizontal*100*Time.deltaTime);
}

function Update(){
	if(Input.GetKey(KeyCode.LeftArrow)){
		moveHorizontal = -1;
	} else if(Input.GetKey(KeyCode.RightArrow)){
        moveHorizontal = 1;
	} else {
		moveHorizontal = 0;
	}	
}

The GameObject the code is attached to, has a polygon collider and a rigidbody2D which has a mass of 0.7 and no drag. In the editor (and also on an Android device) works at the same speed, but in the web player it moves a lot faster.

I thought using Time.deltaTime or even fixedDeltaTime (which I tried too with the same result) would make it framerate independent. What can be the cause of it behaving so differently?

Thank you.

Have the same problem in web player. In my case wheels and bike rotates too fast. Unity version 4.5.1

Problem fixed in 4.5.2 and newer :slight_smile:

You want to use fixedupdate instead of Update, because differences if framerate (web vs pc) causes your object to move faster in update. Fixed update is a the same time per call, which means you move at the same speed no matter the framerate