My sprites are not moving smooth in mobile(Android/IOS). The prefab counts are 4 and at the same time there could be 7-10 prefabs in the game. They are just moving by Y axis down. Here is the code.
`
void Update()
{
Speed = _gameManager.Speed;
transform.Translate(new Vector3(0, 1, 0) * Speed * Time.deltaTime);
}
`
even in videos the problem is visible. Mobile - https://drive.google.com/file/d/1uUklgT5r770nGblZea0bsEpGVErDSoZh/view?usp=share_link
Unity Editor - https://drive.google.com/file/d/1o2f1uMMJtgXe3dbEOCmKjeo92vWDLKKP/view?usp=share_link
The image sizes are 540*540 if this helps
I tried changing textures, decreasing the MaxSize of the image in unity Android build, but none of that helped
CodePudding user response:
Instead of the Update method, try use the FixedUpdate method.
void FixedUpdate()
{
Speed = _gameManager.Speed;
transform.Translate(new Vector3(0, 1, 0) * Speed * Time.deltaTime);
}
You can watch the official Unity's tutorial for the difference between the 2 methods here: Update and FixedUpdate
A quick explanation is that FixedUpdate()
it will run 50 times per seconds that's why it is called fixed. On the other hand Update()
it will run as much as your device can handle, that means if your having a good enough pc it might run more than 60fps but when you test it on a mobile device it might reach the same fps as your pc and that's why you see the difference in the speed.