Animation scripting?

Hi guys,

Kind of urgent question. I’m trying to basically call states of an animation tree in sequence with Cinemachine/Timelines. I basically just want a very scripted encounter in this fashion:

Start scene
NPC 1 says line while executing x animation.
NPC 2 executes x animation and responds with another line.
Player does an action. After the action ends, NPCs continue on to the next line etc.

I’m basically just really confused about how the pieces fit together. Does anyone have a good tutorial or can explain this to me?

What have you tried up to this point, and what was the result? Can you post any code you have so far? Have you looked at the relevant tutorials and documentation for the modules you’re trying to work with?

I’ve made an animation controller and the state machine. I’ve got timelines created for each character. Let me grab screencaps / copy-paste stuff rq.

Animation state machine: Imgur: The magic of the Internet
(Confession, animator made this, idk if it’s proper form at all)

Animation controller (ignore the non-animation stuff, I’ve got some other functionality tacked on here):
using System;
using System.Collections;
using UnityEngine;

namespace LangLand.Script
{
[RequireComponent(typeof(AudioSource))]
public class NPC : Character
{
private AudioSource audioSource;

private Animator animator;

private void Awake()
{
audioSource = GetComponent();
animator = GetComponentInChildren();
}

///


/// Has the NPC speak
///

/// Text displayed while NPC is speaking
/// Audio clean played while NPC is speaking
/// Method to be called when NPC finishes speaking
public override void Speak(string transcript, AudioClip audioClip, Action callback)

{

StartCoroutine(PerformSpeak(transcript, audioClip, callback));
}

public void Dance()

{

ResetAnimations();

animator.SetBool(“Dance”, true);

}

public void Run()

{

ResetAnimations();

animator.SetBool(“Run”, true);

}

public void Sit()

{

ResetAnimations();

animator.SetBool(“Sit”, true);

}

public void ResetAnimations()

{

animator.SetBool(“Run”, false);

animator.SetBool(“Sit”, false);

animator.SetBool(“Dance”, false);

}

///


/// Performs the actual speaking of the NPC
///

/// Text displayed while NPC is speaking
/// Audio clean played while NPC is speaking
/// Method to be called when NPC finishes speaking
/// Unity required IEnumerator
private IEnumerator PerformSpeak(string transcript, AudioClip audioClip, Action callback)
{
yield return new WaitUntil(() => hackyHack);
speechBubble.gameObject.SetActive(true);
speechBackground.gameObject.SetActive(true);

hackyHack = true;

Debug.LogError(“Hackyachck”);

TextMesh Text = GetComponentInParent ();
//speechBubble.
Text = transcript;
audioSource.PlayOneShot(audioClip);
yield return new WaitForSeconds(audioClip.length);
StopSpeaking();
callback(false);
}

///


/// Has the character stop speaking
///

private void StopSpeaking()
{
speechBubble.text = string.Empty;
audioSource.Stop();
speechBubble.gameObject.SetActive(false);
speechBackground.gameObject.SetActive(false);
Animation.Play (false); //stop playing the talking animation

}
}
}

The timelines are currently empty, but I know how to make basic splines, etc. The characters themselvse aren’t really moving much, but I was thinking I’d use the timelines as a vehicle for holding animations over time, if that makes sense.