Forum rules - please read before posting.

Using expression tokens to change animation state

edited November 2020 in Technical Q&A

The manual for adventure creator says that if your character uses mechanim or sprites unity complex then they can utilize expression tokens within speech to change the characters animation state.

The manual is a bit light on details, however, on what exactly that means. Does that mean if my character defines multiple animations and animation states via the animation controller I can use the expression tokens to trigger those animation states? I'm currently trying to do this but not having much luck and the documentation doesn't give many examples on how to do this

Do my animation names or animation state names need to match the expression names?

I could use some assistance as I'm currently stuck spinning my wheels on this.

Comments

  • Here an example. I use either a trigger or a bool (if it is looping) to change the animation states, in this case the face expression, during a dialogue. I set an Actionlist like this:

  • edited November 2020

    When using Mecanim or Sprites Unity Complex, AC animates characters by controlling Animator parameter values. It's the same when using expressions.

    It's possible to insert tokens into your speech text of the form [expression:Name], in order to update a character's active expression. For example:

    [expression:Happy]It's the weekend! [expression:Sad]Oh, but it's raining.
    

    For these to have an effect, you'll need to define "Happy" and "Sad" expressions in your character's Inspector. When doing so, you'll find that expressions each have an ID number, e.g. Happy is 0, Sad is 1, etc.

    If you then go and define an Integer parameter in your Animator, and define that as the character's Expression ID integer, you'll find that this parameter always takes the ID value of the character's active expression.

    So in the example above, it'll be set to "0" when they say "It's the weekend!" and "1" when they say "Oh, but it's raining."

    How you make use of this parameter, however, is more open-ended. You can either use it to trigger transitions between different talking-animations, or you can use a simple script to convert it to a Float parameter and use it in a Blend tree, for example:

    void Update ()
    {
        int expressionID = GetComponent <Animator>().GetInteger ("ExpressionID");
        GetComponent <Animator>().SetFloat ("ExpressionFloat", (float) expressionID);
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.