# Emotions

Since version 1.1.0 it is possible to add emotions to your models.

{% stepper %}
{% step %}
Open `Create > Frostember Studios > FaceSync > Emotion profile`.
{% endstep %}

{% step %}
Assign your model from the project to set up visemes that match your emotions
{% endstep %}

{% step %}
Assign model from scene and click "Preview" to see how your emotion look.
{% endstep %}

{% step %}
Assign profile in FaceSync controller in Emotions & Expressions
{% endstep %}

{% step %}
Test your emotions by pressing "Play"
{% endstep %}
{% endstepper %}

### C\#

```csharp
using UnityEngine;
using Frostember.FaceSync; // Required namespace to access FaceSync components
///

/// An example script demonstrating how to control FaceSync Emotions via C# scripts.
/// This is particularly useful for Dialogue Systems, visual novels, or dynamic in-game events.
///
public class EmotionControllerExample : MonoBehaviour
{
[Header("FaceSync References")]
[Tooltip("Drag and drop your character's FaceSyncController here.")]
public FaceSyncController faceController;[Header("Testing Keys")]
public KeyCode happyKey = KeyCode.Alpha1;
public KeyCode angryKey = KeyCode.Alpha2;
public KeyCode clearKey = KeyCode.Alpha0;

private void Update()
{
    // ---------------------------------------------------------
    // 1. SETTING AN EMOTION
    // ---------------------------------------------------------
    // When triggered, the character will smoothly transition into the "Happy" emotion.
    // The transition speed is determined by the 'Transition Speed' field in the Emotion module.
    // NOTE: The emotion name must exactly match the name defined in the Emotion Profile.
    if (Input.GetKeyDown(happyKey))
    {
        if (faceController != null)
        {
            faceController.SetEmotion("Happy");
            Debug.Log("FaceSync: Emotion set to Happy.");
        }
    }

    // Setting another emotion ("Angry").
    // FaceSync will automatically blend out of "Happy" and smoothly transition into "Angry"
    // without snapping or breaking the active lip-sync speech.
    if (Input.GetKeyDown(angryKey))
    {
        if (faceController != null)
        {
            faceController.SetEmotion("Angry");
            Debug.Log("FaceSync: Emotion set to Angry.");
        }
    }

    // ---------------------------------------------------------
    // 2. CLEARING AN EMOTION
    // ---------------------------------------------------------
    // To return the character's face back to a neutral, default state, call ClearEmotion().
    // This will slowly fade out any active emotions. The character will continue to blink 
    // and do lip-sync normally, but the baseline expression will be neutral.
    if (Input.GetKeyDown(clearKey))
    {
        if (faceController != null)
        {
            faceController.ClearEmotion();
            Debug.Log("FaceSync: Emotion cleared, returning to neutral state.");
        }
    }
}

// ---------------------------------------------------------
// EXAMPLE INTEGRATION (e.g., Dialogue System Event)
// ---------------------------------------------------------
/// <summary>
/// You can call this method directly from Unity Events, 
/// UI Buttons, or custom Dialogue System nodes.
/// </summary>
public void PlayShockedReaction()
{
    if (faceController != null)
    {
        faceController.SetEmotion("Shocked");
    }
}

}
```

### Timeline

{% stepper %}
{% step %}
Open Timeline window and click (+) > Frostember.FaceSync.Timeline > Face Sync Emotion Track.
{% endstep %}

{% step %}
Drag and drop your character into the track's binding slot.
{% endstep %}

{% step %}
Right-click on the track and select "Add Face Sync Emotion Clip".
{% endstep %}

{% step %}
Select the clip and assign your Emotion Profile in the Inspector.
{% endstep %}

{% step %}
Choose your desired emotion from the dropdown menu and scale the clip to blend it seamlessly!
{% endstep %}
{% endstepper %}

<figure><img src="https://3216663219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUhMXol1kUQNRCJY9E1tA%2Fuploads%2FDJhJYglAP63RbxdYltHc%2Fimage.png?alt=media&#x26;token=e6151eed-1342-43ac-b4f3-6b3c09d58652" alt=""><figcaption><p>Emotions &#x26; Expressions in Face Controll component</p></figcaption></figure>

<figure><img src="https://3216663219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUhMXol1kUQNRCJY9E1tA%2Fuploads%2FG5Co6uf3abO5ilam1Ifd%2Fimage.png?alt=media&#x26;token=8e2fe77d-9577-49cd-b889-7c34880706cc" alt=""><figcaption><p>Emotion profile</p></figcaption></figure>

{% file src="<https://3216663219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUhMXol1kUQNRCJY9E1tA%2Fuploads%2F58E2qQqzysjPzaFG1Q3r%2F20260427-1833-39.9464011.mp4?alt=media&token=593d0a2e-4216-4f16-becb-0d725e6bdfb0>" %}
Video emotions
{% endfile %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://frostember-studios.gitbook.io/face-sync/additionals/emotions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
