Porting to Windows: Translate problem

I have Unity on Mac, I created a simple 2d game where player’s position is changed this way:

    if(Input.GetKey(moveUp)){
    	transform.Translate(Vector3(0,speed,0));
    }

on unity and mac is ok but when I port it on windows the translation is like 10 times stronger and so rotation, what’s the problem?

Thanks

You move your object frame dependent. On your mac you might be restricted by v-sync and on windows it runs as fast as it can and you probably got 1000 fps.

The solution is, make it frame-independent by multiplying your speed with Time.deltaTime:

transform.Translate(Vector3(0, speed, 0) * Time.deltaTime);

You probably need to adjust the speed value. Now the speed represents units per second. So a value of 20 will move the object 20 units in one second.

Perfect, thanks :slight_smile: