Intense Lag/Stutter when 3d cube is moving.

Why does it lag/stutter so much when I’m moving my 3d cube downwards?
It’s just a simple 3d cube. I’ve also tried FixedUpdate and Update but I prefer FixedUpdate since in Update, its speed changes drastically depending on the lag, while in FixedUpdate, the speed is constant, but the lag is much greater.

This is the code I’m using right now. Is there something in it that’s making my cube lag? My scene only contains a cube and a light, and while it doesn’t lag that much on my desktop, it lags really hard on my Samsung Galaxy:

using UnityEngine;
using System.Collections;

public class fall : MonoBehaviour {

	public static float speed;

	Vector3 move;
	
	void Awake () {
		
		move = new Vector3(0, -9.0f, 0);

		speed = 4.0f;
		
	}

	// Update is called once per frame
	void FixedUpdate () {
	
			move = new Vector3(transform.position.x, -9.0f, transform.position.z);
			transform.position = Vector3.MoveTowards(transform.position, move, Time.smoothDeltaTime * speed);

		}

	}

}

I’ve also tried Rigidbody.MovePosition and Transform.Translate, but it still lags very hard.

There’s two ways to get smoothed visuals:

Always use Rigidbodies on GameObjects that move. Everything else is considered static and expensive when moved anyway.

  • Manipulate your Transforms in Update() since it’s frame based and make the Rigidbody kinematic. You won’t get proper collision though.
  • Manipulate your velocity in FixedUpdate() and use interpolation mode on your Rigidbody component without being kinematic. Since FixedUpdate() is a different loop than Update and the Rigidbody needs to get a chance to know where it’s going to be during a render call, it can only predict that when it has a velocity.