I’ve been trying to fix this for days and it’s driving me crazy. I’m trying to build a clone of this game:
The concept is simple. There are platforms moving upwards and the player’s job is to control the ball and keep it on the platforms. If the ball the ball hits the spiky platform or the spikes at the top and the bottom, the player loses a life.
However, I’m struggling with moving the platforms. The platform that I’ve created has RigidBody attached and I’m using the function
rb.MovePosition(transform.position + transform.up * Time.fixedDeltaTime); in the platform’s FixedUpdate() function. The RigidBody component of the platform is set to “interpolate” and “isKinematic” is set to true.
In the earlier versions of this game (which I released for Android and then deleted a year later), the movement of the platform was perfect. The platform smoothly moved from the bottom the screen to the top without any shakyness or jitteriness. However, in the version that I’m working in now, the platforms are pretty jittery in movement.
I originally thought it was because I added a lot more game objects and scripts to my game and made it too complex. So I created a new project and moved the platforms there. Unfortunately, the jitteriness didn’t go away.
I’ve tried all kinds of codes for the platform’s movement. I’ve tried using Mathf.MoveTowards, Transform.Translate, Vector3.MoveTowards but nothing is working (I had to change the FixedUpdate to Update because these aren’t using physics properties).
What’s going on? Why did my platforms move so smoothly in the previous versions of my game but not in the current work-in-progress version of my game? I know that I used an older version of Unity for the old versions of the game. Could it have anything to do with this?
Another thing you should know is that in the previous versions of the game, I never set the frame rate to a specific value. But it didn’t matter because the game ran very smoothly. In this version, I tried setting frame rate to 60 but it was no use. The platforms are still shaking as they moves upwards.
I even played around with the Fixed Timestep. Didn’t work.