Move GameObject to exact position

Hi guys, I don’t know if this question was already posted or not, I googled it and I found nothing…

I’m trying to do a very simple thing. Make a game object move from point A to point B in a smooth animation, using C#.
I used: transform.Translate(), Vector3.Slerp() and Vector3.SmoothDamp(), but the result is always the same, I even tried to do it this way:

void Update()
    Vector3 temp = this.transform.position;
    temp.y += 0.2f;
    this.transform.position = temp;

But, the result stills the same…
I want to move the gameObject from (x,0,z) to (x,10,z), but no matter what I do, it never achieves whole results, it stops at 10.01 or 10.2 it never stops in 10. I tried with deltaTime, fixedDeltaTime and smoothDeltaTime, tried do it inside Update and FixedUpdate but it never reaches the exact 10 for y axis… But if I use increments of a unit like :
y += 1;
Then it works, it achieves 10, but it’s way too fast, it doesn’t generates a smooth “animation”…
Can anybody here help me understand why does it happens?

This is a common problem when using float numbers. There is no real solution. You have to detect if it reached the destination with a margin of minimum distance. After detection, you have to set the destination position manually one last time.

For problems like this I normally use Mathf.Clamp() to make sure the value is never greater than the target value (similar process if you are subtracting), then instead of using the Vector3.SmoothDamp() (or anything similar) to get the value I want, I do * 2 for the target, and * 2 for the time, and because the value is clamped, it will never go above the target value.