Advertisement
Guest User

UNITY 3D IK

a guest
Apr 29th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1.     public Vector3 offset_target;
  2.     private Animator mAnimator;
  3.     public Transform target;
  4.  
  5.     Vector3 targetPosition;
  6.     Vector3 dampVelocity;
  7.  
  8.     // Use this for initialization
  9.     void Start () {
  10.         mAnimator = GetComponent<Animator>();
  11.  
  12.     }
  13.    
  14.     void Update () {
  15.  
  16.     }
  17.  
  18.     void OnAnimatorIK() {
  19.         if (activeIK == false) {
  20.             mAnimator.SetLookAtWeight (0, 0, 0, 0, 0);
  21.        
  22.         }
  23.           else {
  24.             targetPosition = Vector3.SmoothDamp(targetPosition, target.position, ref dampVelocity, 0.2f);
  25.             mAnimator.SetLookAtPosition (target.position);
  26.             mAnimator.SetLookAtWeight (1, 1 , 1, 1, 1);
  27.  
  28.         }
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement