Problem with a Lerp function in player

Hello,

I’m having a weird issue. In my game, when my ball enter in a hole (trigger), a coroutine is launched and the ball is first set to kinematic and then have 3 lerp: 1 for align with the hole, another to go a bit down and a final one to eject it.
This is working perfectly fine in editor but when i compile and play with the exe, the ball is kinda teleported/pushed in a direction before making the first lerp and the smoothing is of course suffering from that.
I was betting that maybe this was an issue with isKinematic and maybe this takes more time or add some issue in the player than in the editor but that still sounds weird. So i come here to ask help if you have any suggestion or any idea on what can cause this.

I don’t think the code is the issue since it works on editor but i can share it anyway or at least the part where the problem occurs:

        rigid.isKinematic = true;
        while(Vector3.Distance(trans.position, hole.transform.position) > 0.2f  && !isDestroyed)
        {
            trans.position = Vector3.Lerp(trans.position, hole.transform.position, 2f * Time.deltaTime);
            yield return null;
        }

Thanks in advance for any help!

Ok I figured it out.
I changed the function so that it lerp the rigidbody.position instead of the transform.position.

I read somewhere that transform change or rigidbody have no incidence if the rigidbody is kinematic. That was not totally true! :stuck_out_tongue: