Lag or suffering in OnStateUpdate

I´m trying to throw a arm to the player while the arm is rotating in the animation, but the arm doesn’t move correctly in the update

I do not know what is the problem

    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
   {
        timer = Random.Range(minTime, maxTime);
        animator.SetFloat("timelife", timer);
        rightArm = GameObject.Find("RightArm").GetComponent<Transform>();
        rightArmPos = rightArm.localPosition;
        boss = GameObject.Find("Bossu2Real").GetComponent<BossBehaviour2>();
        player = GameObject.Find("nave").GetComponent<PlayerBehaviour>(); 
        animator.SetBool("isAttackingWithArms", true);
   
        isAtackingWithRightArm = true;
        float lifetime = 0.3f;
    
        direction.Normalize();
        rightArm.transform.position = rightArm.transform.position + direction * armSpeed;
        Debug.Log("posicion" + rightArm.transform.position);
        Debug.Log("Throwing arm");
        animator.SetFloat("timelife", lifetime);
        

             
        }
   

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
   {
         direction = rightArm.position - boss.transform.position;
        direction.Normalize();
        rightArm.transform.position = boss.transform.position + direction * armSpeed;
        //rightArm.position = direction * armSpeed * Time.deltaTime;

        timer -= Time.deltaTime;
        Debug.Log("Brazo en movimiento// Arm in movement");

        if (timer <= 0)
        {
            Debug.Log("He esperado el timer");
            //    Destroy(rightArm.gameObject, lifetime);
            isAtackingWithRightArm = false;
         
            rightArm.localPosition = new Vector3(1.655198f, -1.130143f,0);
            animator.ResetTrigger("isAttackingWithRightArm");

            animator.SetTrigger("idle");
       
        }
      
 
      
        }

The animator is overriding any position changes you’re making in your code.

How can I fix it? the rotate animation only modifies the rotation not the position so I know that is not

i don’t know about using OnStateUpdate, but when i’m trying to get around animations resetting rotations I’m trying to make, for stuff like recoil, or having a characters head face another character, I put my code in LateUpdate because it runs after everything else.