smooth movement in 3d

I am working by myself on a small personal project and I was going to try to see how the movement of my character is going to be handled.

I was planning on using a script similar to what I used in a different project but I realized in that project it was all based on 2d and my new project has also z axis movement:

float sqrRemainingDistance = (transform.position - Final_Run_Spot).sqrMagnitude;

while(sqrRemainingDistance > float.Epsilon)
		{
			//Find a new position proportionally closer to the end, based on the moveTime
			Vector3 newPostion = Vector3.MoveTowards(rb2d.position, Final_Run_Spot, inverseMoveTime * Time.deltaTime);
			
			//Call MovePosition on attached Rigidbody2D and move it to the calculated position.
			rb2d.MovePosition (newPostion);
			
			//Recalculate the remaining distance after moving.
			sqrRemainingDistance = (transform.position - Final_Run_Spot).sqrMagnitude;

Does anybody know how can I make something similar to this only in 3d space?

I changed the code a bit and made it work with some configurations, though not in the way I wanted it to work.

rb.MovePosition(Vector3.MoveTowards(Player.transform.position,BattleGrid[3,0].position,200f));

rb is just RigidBody now.
But I want the player to move at a certain pace to it’s destination. Instead because of the 200f for example he just jumps straight to destination.

The real issue is, I have another code for the movement, though when I test it out (Without the previous code)
The entire unity freezes up and I have to ctrl+Alt+del the unity to try again,

I can’t tell what is happening in this code for the whole engine to crash on play:

float sqrRemainingDistance = (BattleGrid[0,0].position - Player.transform.position).sqrMagnitude;
			while(sqrRemainingDistance > float.Epsilon)
			{
				Vector3 newPostion = Vector3.MoveTowards(rb.position, BattleGrid[0,0].position, inverseMoveTime * Time.deltaTime);
				rb.MovePosition (newPostion);
				sqrRemainingDistance = (BattleGrid[0,0].position - Player.transform.position).sqrMagnitude;

I am very close to fixing the movement so I would be glad if someone offered a hand and helped :slight_smile: