- Home /
Why is the Movement slow on iOS Device but good on Android Device?
Hi all,
I completely finished a game and tested it both for Android and iOS. In the Game (really simple 2D Game) the Player moves automatically forward and you just change his direction by touching the screen to rotate him.
This is the movement Code:
void Update(){
if (Input.GetMouseButton(0))
{
Vector3 touchposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (touchposition.x < 0) { rotation = 5; }
else if (touchposition.x > 0) { rotation= -5; }
transform.Rotate(0, 0, rotation);
}
}
private void FixedUpdate()
{
rigidbody.velocity = 10* transform.up;
}
The Movement worked perfectly on Windows Unity Editor and on two Android Test Devices. Then I moved the whole Project to a Macbook and switched the Unity Platform to iOS. In the Unity Editor the Movement was still working as fine as before. But then I exported the App on my iPhone (building in Unity, then opening on XCode and finally Running on Device). On my Iphone the Player moves forward at the same speed as in all other tests (Android Devices, Windows Unity Editor, Mac Unity Editor). But the rotation is really slow! It is like the rotation amount, which is 5, is somehow reduced to 1. I thought maybe this is because my iPhone Touchscreen doesn't work properly, but other games run normally.
So what is the issue here?
Thanks!
Answer by frederikedel · Jun 20, 2020 at 12:04 PM
The problem ist that the speed is fixed to the Framerate of the Device. You have to multiply it by Time.deltaTime
That was it! Thank you! I changed the code:
rotation = 5* Time.deltaTime / 0.02f;
0.02 was the fixed Timestep in Unity, so this is my scale.
Cheers