Cant override animations with scripts?
I have a character made out of parts.... and animations are made by changing the transform of those parts and those animations work just fine , BUT I cant override those transforms in script for some reason
My character has animation, where he takes "aiming stance" and then I need to use script to aim - rotate parts like hands towards mouse ... What´s even weirder is that 1 part ( his left hand ) is rotating, and other parts dont ... I´ve tried to look for solution to this problem and all I found was "try to override it in LateUpdate" or "Animate Physics in Animator´s properties"... they work, sort of.... those other parts start flickering on spot,when they try to rotate, but actually dont rotate at all ( the left hand is still rotating properly )
My script for rotation :
 public class Aim : MonoBehaviour {
     public Animator animator;
     public Transform LeftArm;
     public Transform RightArm;
     public Transform Rifle;
 
     void Update () {
         if (Input.GetKey(KeyCode.Mouse1)) {
             animator.SetBool("isAiming", true);
             Aiming();
         }
         if (Input.GetKeyUp(KeyCode.Mouse1)) {
             animator.SetBool("isAiming", false);
         }
     }
     
     private void Aiming() {
         Vector2 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - Rifle.position;
         float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
         Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
 
         Rifle.rotation = Quaternion.Slerp(Rifle.rotation, rotation, 5f * Time.deltaTime);
         LeftArm.rotation = Quaternion.Slerp(LeftArm.rotation, rotation, 5f * Time.deltaTime);
         RightArm.rotation = Quaternion.Slerp(RightArm.rotation, rotation, 5f * Time.deltaTime);
         
     }
 }
 
              Your answer
 
             Follow this Question
Related Questions
Animation locks transform, even when not playing 0 Answers
Animator and code controlled bone rotations 0 Answers
I can not modify localscale while I'm playing because of the Animator. 1 Answer
Simple animator/animation problem 0 Answers
What is causing animation Position strange position changes 0 Answers