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

IK Aiming help

Discussion in 'Animation' started by AkhmedAbasov, Aug 7, 2018.

  1. AkhmedAbasov

    AkhmedAbasov

    Joined:
    Mar 13, 2014
    Posts:
    163
    [Sorry for my bad english.]
    I've already spent a lot of time trying to solve this problem. I need the skeleton of the character to rotate down / up following the crosshair.

    When I'm using SetLookAtPosition, my character puts his hands to the left and up.

    Code (CSharp):
    1.  
    2. animator.SetLookAtWeight(1, 1f, 1f, 1);
    3. animator.SetLookAtPosition(cameraLookPoint.position);
    4.  
    12.png 13.png


    I want to watch it should be at the point in the center of the camera.
    How is this problem solved? My animation without IK is direct and has no deviations. IK breaks animation.
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    A LookAt is not an AimAt.

    a look at will align the forward vector(Z axis) of a transform toward a target.
    the animator built in look at does affect the chest, neck, head and eyes. So it really hard to align the gun on a target by changing the rotation of thoses 4 transforms, the only one really affecting the alignement on the gun is the chest.

    The basic idea is to align the forward vector of the gun toward the target and then apply IK on the hands to reach the gun. Some game adjust the position of the character first to avoid any weird pose too.