Object movement synchronization

Hi,

I have a platform script that moves an object back and forth between 2 way points, but over time they loose synchronization and their timings are off by +/- 0.02

This is the move code in Fixed update as im moving a rigidbody

 platformRigid.position = (platform.transform.position + direction * platformSpeed * Time.deltaTime);

and this is the code to check when the object reaches its way point

     if (Vector2.Distance(platformRigid.position, destination.position) <= (platformSpeed * Time.deltaTime) && !paused)
     {
         SetDestination(destination == startTransform ? endTransform : startTransform);
        
     }

Does anyone know how to solve this?

Thank you

Modifying the field position doesn’t take interpolation into account. Use RigidBody.MovePosition instead of modifying the position field directly inside your FixedUpdate loop.