Search Unity

SetLookAtPosition inaccurate?

Discussion in 'Animation' started by BernieRoehl, Sep 12, 2013.

  1. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    I'm trying to get an avatar to look at the camera. Sounds easy enough.

    Here's my code:

    Code (csharp):
    1. #pragma strict
    2.  
    3. private var animator : Animator;
    4.  
    5. function Start () {
    6.     animator = GetComponent(Animator);
    7. }
    8.  
    9. function OnAnimatorIK() {
    10.     animator.SetLookAtPosition(Camera.main.transform.position);
    11.     animator.SetLookAtWeight(1.0);
    12. }
    I'm using the standard Mixamo "Carl" avatar with the "Idle-Ready" animation from the "Raw Mocap Data" in the Unity Asset store. Again, all very straightforward.

    The result is that Carl is looking somewhere other than at the camera. As I move the camera, Carl does look vaguely in the general direction of the camera, but he's not facing me and definitely not making eye contact.

    $carl_ik_issue.jpg

    Anyone know how I can get Carl to pay attention?
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Did Carl's avatar map correctly? (Check Import Rig > Configure...) Maybe the auto-mapper picked up the wrong bones for the head/eyes.
     
  3. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    81
    Yes, I checked that and it looks fine.
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Does the problem happen with a different model?

    With a different animation?

    With a different IK target instead of the camera?

    Just trying to narrow down the issue.

    Edit: Also, is the animation jittery or smooth? If it's jittery, maybe something else is taking control of the bones after OnAnimatorIK.
     
    Last edited: Sep 19, 2013