Adventure Creator Wikia

The [expression:ID] token, when inserted into speech text, allows you to change a character's expression - provided you've set up Animation parameters or shapekeys.

However, it doesn't offer much control beside which expression to change to. The script below allows you to set shape key values with control over their intensity and transition time - through use of the token syntax:



  • shape is the token key (don't change this)
  • group is replaced by the group ID
  • key is replaced by the label of the key within that group
  • value is replaced by the new value
  • transition is replaced by the transition time

When inserted into a character's speech text, this token will then be processed and used to update the character's Shapeable component, provided they have one.

To use it:

  1. Create a new C# script named ShapeableTokens.cs and paste in the script below
  2. Attach thew new Shapeable Tokens component to any character's root that you want to be able to use this.
  3. Each such character must have a Shapeable component in their hierarchy, with their shapekeys defined in the Inspector
  4. The [shape:X] token detailed above can then be inserted into their speech text.


	using UnityEngine;
using AC;

public class ShapeableTokens : MonoBehaviour

private void OnEnable ()
KickStarter.dialog.SpeechEventTokenKeys = new string[1] { "shape" };
EventManager.OnSpeechToken += OnSpeechToken;

private void OnDisable () { EventManager.OnSpeechToken -= OnSpeechToken; }

private void OnSpeechToken (AC.Char speakingCharacter, int lineID, string tokenKey, string tokenValue)
if (speakingCharacter != GetComponent <AC.Char>()) return;

if (tokenKey == "shape")
string[] valueArray = tokenValue.Split ("_"[0]);
if (valueArray.Length == 4)
int groupID = 0;
string keyName = valueArray[1];
float value = 0f;
float transition = 0f;

if (int.TryParse (valueArray[0], out groupID) &&
float.TryParse (valueArray[2], out value) &&
float.TryParse (valueArray[3], out transition))
Shapeable shapeable = speakingCharacter.GetComponentInChildren <Shapeable>();
shapeable.SetActiveKey (groupID, keyName, value, transition, MoveMethod.Smooth, null);