Hi, I'm trying to create an action to change the expressions, since the speech actions with expressions only start some mouth moving.
How do I get the expression enum list for a dropdown list so I wouldn't need to set the strings and remove human errors?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
There's no expression enum - expressions are defined per-character, so you need to know which character you're affecting before you can extract their available expressions.
To expose a dropdown list, you'll want to use Unity's EditorGUILayout.PopUp function, which requires a string array of the various options. You can get such an array for a particular character with this function:
I did this:
`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;
if UNITY_EDITOR
using UnityEditor;
endif
[System.Serializable]
public class MakeExpression : Action
{
public override ActionCategory Category { get { return ActionCategory.Custom; }}
public override string Title { get { return "Show expression"; }}
public override string Description { get { return "Makes expression to a character."; }}
}`
It works fine, but now I started to wonder if I could add also a sound - like a little laugh or cough. Since they are connected to a person also like speech, would it be possible - or feasible - to try to combine them to one Action?
You could add an AudioClip variable, exposed in ShowGUI, and then played via character.AudioSource.PlayOneShot in Run.
However, if you're looking to have the same expression type result in the same audio (even if only per-character), then it'd be better to automate it through events.
There isn't currently an event for when a character changes expression, but I shall look to include this as part of the upcoming 1.73.7 update. Bump this thread after the release if you're interested, and I'll post a sample script.
I notice that this script no longer works since I started using Timelines. It seems to capture the character in play. Is there anything I could do?
If you're using Timeline, you can either create a separate animation layer for a character to handle facial animation/expressions, or create Speech tracks that contain [expression:ID] tags.