Search Unity

Check if IK LookAt has reached the max rotation

Discussion in 'Scripting' started by MikeyJY, Apr 19, 2020.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I have an video to explain:


    As you can see at the 0:21 from video if I'm behind the enemy and he can't rotate his had to much because it reached the max. How to check in c# when this maximum angle rotation for has is reached. If it is reached, i will move the entire body.
    Code:
    Code (CSharp):
    1. private void OnAnimatorIK()
    2.     {
    3.         animator.SetLookAtWeight(1);
    4.         animator.SetLookAtPosition(Target.transform.position);
    5.     }