How can I move a rigidbody to a desired position with interpolation?

Hi

I have a rigidbody player I want to move to a desired position. I don’t want it to move it like you would normally have a player move. I just want to move it from Point A to Point B with interpolation, like using Vector3.Lerp. The reason I want to use the rigidbody instead of V3.Lerp is because the lerping slows down the closer it gets to the target and that messes with my code and the feel of of the player.

So this is the two ways I’ve tried doing this.

void FixedUpdate()
{
    rig.MovePosition(movePosition * Time.deltaTime * moveSpeed);
}

The problem with this is that the player just gets stuck at around 0,0,0 and can not be moved. I have no idea what is going on when this happens.

Then I tried this.

void FixedUpdate()
{
    rig.MovePosition(tr.position + movePosition * Time.deltaTime * moveSpeed);
}

The problem with this is that the player keeps walking endlessly since it is always adding the movePosition and transform position.

I have no idea what I am supposed to now.

Any help with this is greatly appreciated!

Use Vector3.MoveTowards() this will result in a constant speed movement from the start position to the target position.

Unity - Scripting API: Vector3.MoveTowards (substitute rigidbody.movePosition for transform.position in the script reference example).

You can compare your rigidbody.position with target position and when they are close enough you can stop moving.

Edit: Vector3.Lerp() can produce the same result as movetowards if it’s used properly, i.e. not with Time.deltaTime as the 3rd parameter.

unfortunately, your transformation method is not correct, since objects move in jerks, I would like to get a smooth movement of objects using physics