First object jumps on re-entry of second colliding object

The scenario is that I have two objects – Object A and Object B. The Object A is lying on the ground and when Object B enters the collider of Object A, the Object A moves (only X and Z axis) with Object B. The movement works well with the script shown below.

The issue is that most of the time, the Object A’s initially position shifts by few meters whenever Object B enters its collider. I feel it is related to offset position. What should happen is that, Object A should be the same position when Object B enters the collider and move along with Object B only when Object B moves.

So how do I fix this?

private Vector3 offsetPosition;  public Transform ObjectB;  public bool ObjectB_Collision = false;  void Start () {         offsetPosition = ObjectB.transform.position - this.transform.position;     }      void ObjectB_HasEntered() {         offsetPosition = ObjectB.transform.position - this.transform.position;     }       // Update is called once per frame     void LateUpdate () {          if (ObjectB_Collision == true) {             this.transform.position = new Vector3 (ObjectB.transform.position.x, this.transform.position.y, ObjectB.transform.position.z) - new Vector3 (offsetPosition.x, 0, offsetPosition.z);         }      }  public void OnTriggerEnter (Collider col) {         if (!enabled) return;          if ( == "Object_B") {             ObjectB_HasEntered();             ObjectB_Collision = true;         }     }   public void OnTriggerExit (Collider col) {         if (!enabled) return;         if ( == "Object_B") {             ObjectB_Collision = false;          }     } ```