Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug OnAnimatorIK() stopped working after Unity update

Discussion in 'Animation' started by Recluse, Jan 22, 2022.

  1. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    After updating to Unity 2021.2.2f1...

    Humanoid characters no longer look at things.

    Animators have IK pass and looking is implemented using OnAnimatorIK() and animator.SetLookAtPosition, animator.SetLookAtWeight.

    This occurs in all projects.

    After reinstalling Unity 2020 LTS - no problems, animator IK works as usual.

    Is there a known bug? Has implementation changed?
     
  2. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    I'm experiencing this issue on models which use the animation rigging system. In fact, after removing it from a character, there seems to be vestigial hurdles stopping onanimatorik from working. onanimatorik only works on the character I've never applied the animation rigging system to.
     
  3. Redellion

    Redellion

    Joined:
    Feb 13, 2014
    Posts:
    2
    Also experiencing this issue.

    OnAnimatorIK is being executed and then calls SetLookAtWeight and then SetLookAtPosition, this code worked fine in Unity 2019.

    I did have animation rigging installed but I have since removed and it the problem still persists.

    Any ideas?
     
    Last edited: May 3, 2022
  4. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    Still a problem, blocking my project. Why doesn't IK work since updating???
     
  5. MarekUnity

    MarekUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    203
    @Recluse I checked it on my side and OnAnimatorIK and SetLookAtPosition works fine. Maybe there is something in your setup that triggers a bug. Can you submit a bug report?
     
  6. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    I made a couple of changes to my IK script :

    changed OnAnimatorIK() to OnAnimatorIK(int layerIndex)

    this didn't seem to have any effect.

    Then I swapped the order so LookAtPosition is set before LookAtWeight in the IK callback.

    Suddenly, the script worked again.
    Weirdly, swapping the order of the position and weight back again didn't make any difference, so I am left without any real clue.

    I attach the script if you want to take a look.

    Oh, and just to confirm - IK pass was enabled at all times in the Animator.

     

    Attached Files:

  7. MarekUnity

    MarekUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    203
    @Recluse OnAnimatorIK(int layerIndex) is the correct overload that you should be using.

    I checked your script and don't see anything wrong with it. For readability it's better to use proper code tags. The order in which you Do I understand correctly that it's working fine now?