> For the complete documentation index, see [llms.txt](https://frostember-studios.gitbook.io/face-sync/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://frostember-studios.gitbook.io/face-sync/additionals/ik-look-at.md).

# IK Look At

Since version 1.2.0 it is possible to add IK to your models.

{% stepper %}
{% step %}
**Select your character** in the hierarchy and expand the `🎯 IK Look Tracking` section in the FaceSync Controller.
{% endstep %}

{% step %}
**Toggle the checkbox** to enable the module and assign a Transform to the `Look Target` field.
{% endstep %}

{% step %}
**Add elements** to the `Head Bones` and `Eye Bones` lists and assign your character's bone Transforms (e.g., Neck, Head, Left Eye).
{% endstep %}

{% step %}
**Set the correct `Forward Axis`** for each bone (usually Positive Z) and adjust the `Max Angle` to prevent unnatural twisting.
{% endstep %}

{% step %}
**Adjust the `Smooth Speed`** and `Influence` weights to fine-tune how fast and how much each bone reacts.
{% endstep %}

{% step %}
**Press "Play"** and move your target in the Scene view to see the character track it dynamically.
{% endstep %}
{% endstepper %}

### C\#

```csharp
using UnityEngine;
using Frostember.FaceSync;
///

/// A demonstration script showing how to dynamically control the FaceSync IK Look Tracking system via C#.
/// This script can be attached to any GameObject in your scene to control a character's focus.
///
public class FaceSyncIKExample : MonoBehaviour
{
[Header("FaceSync Controller Reference")]
[Tooltip("The main FaceSync component on your character.")]
public FaceSyncController faceController;[Header("Look Targets")]
[Tooltip("The default target the character should look at (e.g., the Main Camera or Player).")]
public Transform mainPlayer;

[Tooltip("A secondary target to shift the character's focus to during an event.")]
public Transform interestingItem;

void Start()
{
    // Automatically attempt to find the FaceSyncController if it wasn't assigned in the Inspector.
    // This is useful if this script is attached directly to the character.
    if (faceController == null)
        faceController = GetComponent<FaceSyncController>();

    // IMPORTANT: Ensure your FaceSyncController has the "IK Look Tracking" module enabled 
    // in the Inspector, and that you have assigned the appropriate Head/Eye bones.

    // Immediately set the initial look target. The character will smoothly transition 
    // to looking at the 'mainPlayer' based on the "Smooth Speed" defined in the FaceSync inspector.
    faceController.SetLookTarget(mainPlayer);
    
    // Set the global weight of the IK system (0.0 to 1.0). 
    // 1.0 means the character will fully track the target using the Max Angles defined on their bones.
    faceController.SetIKWeight(1f);
}

void Update()
{
    // ==========================================
    // 1) SWITCHING TARGETS DYNAMICALLY
    // ==========================================
    if (Input.GetKeyDown(KeyCode.Space))
    {
        // Simply pass a new Transform to shift the character's attention.
        // The FaceSync pipeline automatically handles the smooth mathematical Slerp 
        // from the old target to the new one—no manual interpolation code is required!
        faceController.SetLookTarget(interestingItem);
        
        Debug.Log("Character's focus smoothly shifted to the interesting item.");
    }

    // ==========================================
    // 2) ADJUSTING TRACKING INTENSITY (WEIGHT)
    // ==========================================
    if (Input.GetKeyDown(KeyCode.H))
    {
        // Lowering the weight blends the IK tracking with the character's base animation.
        // At 0.5f, the character will only rotate halfway towards the target, 
        // smoothly prioritizing their original Idle/Walk animation and procedural head noise.
        faceController.SetIKWeight(0.5f);
        
        Debug.Log("IK Tracking weight reduced to 50% blend.");
    }

    // ==========================================
    // 3) CLEARING THE TARGET (STOP TRACKING)
    // ==========================================
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        // By clearing the target, FaceSync automatically interpolates the internal weight down to zero.
        // The character's head and eyes will seamlessly return to their default animated pose 
        // without any sudden snapping or robotic jerking.
        faceController.ClearLookTarget();
        
        Debug.Log("Look Target cleared. Character is gracefully returning to their base animation.");
    }
    
    // ==========================================
    // 4) RESTORING FULL TRACKING
    // ==========================================
    if (Input.GetKeyDown(KeyCode.R))
    {
        // Re-assign the player target and restore full tracking weight.
        faceController.SetLookTarget(mainPlayer);
        faceController.SetIKWeight(1f);
        
        Debug.Log("Restored full focus back to the Main Player.");
    }
}
}
```

<figure><img src="https://3216663219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUhMXol1kUQNRCJY9E1tA%2Fuploads%2Fr6wcjxqwUUKoHNGAhqjP%2Fimage.png?alt=media&amp;token=c074fd41-4abd-449e-af92-95be6ff0fa53" alt=""><figcaption><p>IK Look Tracking in Face Controller component</p></figcaption></figure>

{% file src="/files/ihU6zJNrm0ECEDEf6x7O" %}
Video of IK look at
{% endfile %}
