Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel6
outlinefalse
typelist
printablefalse

Overview

This article describes how to set up a Character with an Animation Controller and control which animation triggers using Storyflow. This article assumes that you have a character and multiple animations already in Unity.

...

Unity - Character & Animation Controller Setup

Character

  1. In the Hierarchy, right click on the character and select Motive

...

  1. > Make Scene Object

  2. In the Inspector, in the Motive Scene Object script find the Name field and give the character a name

...

This is the name that will be used in Storyflow. In this example, the name is Animated James.

  1. In the Inspector, make sure that your character has an Animator component

...

  1. If the Controller field is populated, you can remove what is there. We will create a new controller for the character.

  2. Save the project

Animation Controller

  1. In the Project, create a new Animation Controller. This will open the Animator window.

...

  1. (AnimatedJamesController in our example)

  2. Drag in an

...

  1. Animation into the Animator window. This will be the default animation.

...

  1. (The example uses an Idle animation which loops (Stand_Idle_01). )

  2. Add additional animations to the Animator window

...

  1. (In the example, we will use one more animation Stand-Gesture-Up_01

...

  1. )

  2. Right click on the first animation (Idle) and select

...

  1. “Make Transition”

  2. Attach the arrow to one of the other animations

...

  1. In the Animator window, select Parameters

...

  1. Create a Trigger

...

  1. (In the example, we will create the IdleToGestureUp trigger.)

  2. Select a

...

  1. Transition

  2. In the Inspector, uncheck

...

  1. “Has Exit

...

  1. Time”

  2. In the Conditions section add the appropriate trigger

...

    1. In the example, the transition between Stand_Idle_01 state and Stand-Gesture-Up-01 adds the IdleToGestureUp trigger as the condition.

In this case, we want the animation to transition back to the default animation once it has completed.

  1. Create a

...

  1. Transition that starts with Stand-Gesture-Up_01 and goes to Stand_Idle_01

...

  1. For this transition,

...

  1. “Has Exit

...

  1. Time” should remain checked

...

  1. Save the project

...

Character

  1. In the Hierarchy, select the

...

  1. Character

  2. In the Inspector, add an Animator Controller State Listener script

...

  1. Enter a name into the State field. This name is needed for the Behaviour Model which will be created on Storyflow.

...

  1. (In the example, the state is named JamesAnimationState

...

  1. )

  2. Save the project

...

  1. In the Inspector, in the Animator component, assign the Animation Controller to the Controller field

...

  1. In the Animator component, click the

...

  1. “Enable Behaviour Model

...

  1. Usage” button

...

Info

If you have used this button before, it will be called

...

“Update Behaviour Model

...

File”. It will perform the same function.

  1. Save the project

...

Storyflow

Catalog Items

Add the Character to a Catalog

  1. If you have not already done so, create a Named Object

...

  1. Catalog for the

...

  1. Character

  2. Add an item to the

...

  1. Catalog

  2. Give it the same name as the name given to your character in the Name field of the Motive Scene Object script

...

  1. Save the Catalog

...

Add an Enum

...

On the right hand side of Storyflow, select the Enums button.

  • The button looks like a list. This will expand the Enum Definitions section.

...

  1. Create an Enum

  2. Enter the name of your animation into the

...

  1. “New Enum Item Name

...

  1. field” and press enter

...

  1. (In this example, it is Stand-Gesture-Up_01

...

  1. )

You can collapse the Enums Definitions section at this point.

Add a Behaviour Model

  1. If you have not already done so, create a Behaviour Model

...

  1. Catalog

  2. Add an item to

...

  1. the Catalog

  2. Give the Catalog item a relevant name

...

  1. (In the example, the name is James Model

...

  1. )

  2. Add a state to the Behaviour Model

...

The state needs to have the same name that was used in the State field in the Animator Controller State Listener script.

...

In the example, the state is named JamesAnimationState.

  1. Ensure the

...

  1. “Value Definition” is set to Enum and the name of the Enum that was just created. (In this

...

  1. example: JamesAnimationsEnums)

  2. Save the Catalog

...

Storyflow Script to Test

  1. Create a new Storyflow

...

  1. Script

  2. Name the first child

...

  1. Frame Setup

  2. Add the

...

  1. Character from your Named Object catalog into the Resources section of the Frame. This will appear as a Scene Object Resource in your

...

  1. Script (in the example

...

  1. : James Animated

...

  1. )

  2. Click the + button on Main Frame to create another child

...

  1. Frame

  2. Name the

...

  1. FrameBehaviour Models

...

  1. Add a Behavior Model Resource to the Frame

...

  1. Select the Scene Object as the Target

...

  1. (in this example: Animated James

...

  1. )

  2. Add the Behaviour Model that was created in the previous step

...

  1. (in this example: James Model

...

  1. )

  2. A drop down menu will now be visible with the name of the State above it

...

  1. (In

...

  1. this example

...

  1. : JamesAnimationState

...

  1. )

  2. Click the + button next to the drop down field to create a

...

  1. Variable

  2. Give the

...

  1. Variable a name and click the checkmark button

...

  1. Create a new child

...

  1. Frame

  2. Add a Screen Message Resource (Playable Content type)

  3. Enter Animation Test for the Title and Close this message to Animate for the Message field

...

  1. Select the Event Link Shortcut (blue button with a white +) at the bottom of the Screen Message Resource and select

...

  1. “Close”

  2. In the new

...

  1. Frame, add the Variable that was created earlier into the

...

  1. Frame

  2. Assign it the name of one of the animations from the drop down menu. This list displays the enum items which we created earlier

...

  1. (In the example

...

  1. = Stand-Gesture-Up_01

...

  1. )

  2. Save the

...

  1. Script

...

  1. Link the

...

  1. Script to a

...

  1. Scenario

  2. Save the Scenario

Unity or VR Headset - Run the Storyflow Test Script

  1. Run the

...

  1. Scenario linked to the

...

  1. Test Script in Unity or in a VR headset

...

The character will initially be in the default animation state.

When the Screen Message is closed, the the character will transition into the animation defined the Storyflow script.

Chain Multiple Animations

This describes how to have one animation play directly after another and then transition back to the default animation. In this example, we want to trigger the Stand-Gesture-Up_01 animation, then have the character nod directly after and finally return to the Stand_Idle_01 animation.

Unity

  1. Open the Animation Controller which is assigned to the Character

...

  1. Delete the transition that goes from Stand-Gesture-Up_01 to Stand_Idle_01

...

  1. Add an additional Animation. We will use Stand_NodYes_02

...

  1. Create a transition from Stand-Gesture-Up_01 to Stand_NodYes_02

...

    1. On this transition, we want

...

    1. “Has Exit

...

    1. Time” to be checked

...

  1. Create a transition from Stand_NodYes_02 to Stand_Idle_01

...

    1. On this transition, we want

...

    1. “Has Exit

...

    1. Time” to be checked

...

  1. Save

...

  1. In the Hierarchy, select the character

...

  1. In the Animator component, click the

...

  1. “Update Behaviour Model

...

  1. File” button

...

  1. Save the project

...

Unity or VR Headset - Run the Storyflow Test Script

  1. Run the same

...

  1. Scenario as before

...

This time, when the Stand-Gesture-Up_01 animation is triggered, it will transition to Stand_NodYes_02 when complete. When Stand_NodYes_02 is complete, it will transition to Stand_Idle_01.

Related Articles

Characters and Character Actions

Expression Maps

Lip Syncing

Troubleshooting Lipsync Setup