I am working on a 3D platformer in Unity and I am targeting Android devices. The game consists of a lot of objects smoothly interpolating from the bottom of the screen to the top.
This whole time I've been testing my game at 60 fps and the performance was quite good. However, when I tested the game at 30 fps, the interpolation of the objects was no longer smooth.
I initially thought that I have way too many objects in my scene and this might be affecting the interpolating performance. So I created a new project which only has the interpolation stuff and object pooling (you can download it here). But even then, the interpolation wasn't smooth at 30 fps. Here's the code I'm using for interpolating the object:
void FixedUpdate()
{
rb.MovePosition(transform.position + transform.up * Time.fixedDeltaTime * speed);
}
I'm using the object's Rigidbody to interpolate it. I've already set the rigidbody to "Interpolate" and I turned on "isKinematic".
I first thought that the interpolation isn't smooth since I'm using Rigidbody. So I ditched the rigidbody and used transform.Translate
instead. But even then the interpolation wasn't smooth. Next I tried Vector3.Lerp
. Nope. That didn't work either. The stutter was still there. I even tried Vector3.MoveTowards
. That didn't work. The interpolating was still laggy. I even tried turning on GPU instancing for the objects being interpolated (since they all use the same material). That didn't do it either.
Next I started playing around with the fixed timestep (in the Time settings). I thought that maybe if I set the timestep to 0.033, then the objects will interpolate smoothly at 30 fps. But that didn't work either.
I think it's really bizarre that a simple interpolation performs so poorly at 30 fps on an Android device. If the interpolation is only for a short distance, then you don't always notice the stutter. But like I said, in my game the objects have to interpolate from the bottom of the screen all the way to the top. In this case, you can clearly see the laggy movement during interpolation.
Is it possible that long distance interpolation is simply unfeasible for Android devices at 30 fps? How do so many Android game developers manage to achieve good performance at 30 fps? Feel free to download the new project I mentioned which only has the interpolation stuff and the object pooling. It is available here. It's a very simple projects. It only has the prefab that should be interpolated, the material for the prefab, the script for interpolating the prefab, the spawning and object pooling system (for spawning the prefab), and the script for setting frame rate to 30. That's it.
Below a gif of the objects' interpolation. It's not as shaky in reality (since I had to use a bad screen recorder and compress the gif) but it's still pretty close to how the objects move at 30 fps.