Superliminal Perspective Mechanic

I’m trying to replicate the operation of the mechanics of the superliminal game, and so far the scaling works correctly, the only problem is that when I relocate the grabbed object it overlaps with what is placed, for this I read that I could use Physics.OverlapBox, but after the second execution of the update, it recalculates in loop the position and the scale, could you give me advice on how I can avoid it?

private void Grab()
    {
        RaycastHit hit;
        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, Mathf.Infinity, grabbableLayer))
        {
            if (hit.collider.CompareTag("Grabbable"))
            {
                grabbedGameObject = hit.collider.gameObject;

                Rigidbody rb = grabbedGameObject.GetComponent<Rigidbody>();
                Collider col = grabbedGameObject.GetComponent<Collider>();

                if (rb != null) rb.isKinematic = true;
                if (col != null) Physics.IgnoreCollision(playerCollider, col, true);

                grabbedGameObject.transform.SetParent(holdPosition);

                // Save originals
                originalDistance = Vector3.Distance(Camera.main.transform.position, grabbedGameObject.transform.position);
                originalScale = grabbedGameObject.transform.localScale;

                Debug.Log($"Objeto agarrado: {grabbedGameObject.name}, Distancia Original: {originalDistance}");

                isHoldingObject = true;
            }
        }
    }

    private void UpdateObjectPosition()
    {
        if (grabbedGameObject == null) return;

        RaycastHit hit;
        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, Mathf.Infinity, resizableLayer))
        {
            float hitDistance = Vector3.Distance(Camera.main.transform.position, hit.point);
            repositionedDistance = hitDistance;

            Vector3 newScale = originalScale * (repositionedDistance / originalDistance);
            if (newScale.magnitude >= 10f) newScale = Vector3.one * 10f;

            Debug.Log($"Distancia Hit: {hitDistance}, Distancia Reposicionada: {repositionedDistance}, Nueva Escala: {newScale}");

            if (repositionedDistance <= 3.0f)
            {
                Debug.Log("Distancia muy cercana, deteniendo ajuste");
                return;
            }

            grabbedGameObject.transform.position = hit.point;
            grabbedGameObject.transform.localScale = newScale;
        }
    }

II finally got this solution, I still have to adjust the reps in the position setting but it is a functional improvement.

private void UpdateObjectPosition()
    {
        if (grabbedGameObject == null) return;

        RaycastHit hit;
        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, Mathf.Infinity, resizableLayer))
        {
            float hitDistance = Vector3.Distance(Camera.main.transform.position, hit.point);


            if (hitDistance <= 3.0f)
            {
                Debug.Log("Distancia muy cercana, deteniendo ajuste");
                hitDistance = 1.5f;
            }

            Vector3 newScale = originalScale * (hitDistance / originalDistance);
            if (newScale.magnitude >= 5f) newScale = Vector3.one * 5f;

            Debug.Log($"Distancia Hit: {hitDistance}, Distancia Reposicionada: {repositionedDistance}, Nueva Escala: {newScale}");

            grabbedGameObject.transform.position = hit.point;
            grabbedGameObject.transform.localScale = newScale;

            Collider[] colliders = Physics.OverlapBox(grabbedGameObject.transform.position, grabbedGameObject.transform.localScale * 0.5f, grabbedGameObject.transform.rotation, resizableLayer);

            Debug.Log("Colisiona con: " + colliders.Length);

            int i = 0;
            while (i < colliders.Length)
            {
                Vector3 offset = -Camera.main.transform.forward * newScale.magnitude / 2;
                grabbedGameObject.transform.position = hit.point + offset;
                i++;
            }

        }