Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
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
In the Hierarchy, right click on the character and select Motive
...
> Make Scene Object
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.
In the Inspector, make sure that your character has an Animator component
...
If the Controller field is populated, you can remove what is there. We will create a new controller for the character.
Save the project
Animation Controller
In the Project, create a new Animation Controller. This will open the Animator window.
...
(AnimatedJamesController in our example)
Drag in an
...
Animation into the Animator window. This will be the default animation.
...
(The example uses an Idle animation which loops (Stand_Idle_01). )
Add additional animations to the Animator window
...
(In the example, we will use one more animation Stand-Gesture-Up_01
...
)
Right click on the first animation (Idle) and select
...
“Make Transition”
Attach the arrow to one of the other animations
...
In the Animator window, select Parameters
...
Create a Trigger
...
(In the example, we will create the IdleToGestureUp trigger.)
Select a
...
Transition
In the Inspector, uncheck
...
“Has Exit
...
Time”
In the Conditions section add the appropriate trigger
...
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.
Create a
...
Transition that starts with Stand-Gesture-Up_01 and goes to Stand_Idle_01
...
For this transition,
...
“Has Exit
...
Time” should remain checked
...
Save the project
...
Character
In the Hierarchy, select the
...
Character
In the Inspector, add an Animator Controller State Listener script
...
Enter a name into the State field. This name is needed for the Behaviour Model which will be created on Storyflow.
...
(In the example, the state is named JamesAnimationState
...
)
Save the project
...
In the Inspector, in the Animator component, assign the Animation Controller to the Controller field
...
In the Animator component, click the
...
“Enable Behaviour Model
...
Usage” button
...
Info |
---|
If you have used this button before, it will be called |
...
“Update Behaviour Model |
...
File”. It will perform the same function. |
Save the project
...
Storyflow
Catalog Items
Add the Character to a Catalog
If you have not already done so, create a Named Object
...
Catalog for the
...
Character
...
Give it the same name as the name given to your character in the Name field of the Motive Scene Object script
...
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.
...
Enter the name of your animation into the
...
“New Enum Item Name
...
field” and press enter
...
(In this example, it is Stand-Gesture-Up_01
...
)
You can collapse the Enums Definitions section at this point.
Add a Behaviour Model
If you have not already done so, create a Behaviour Model
...
...
Give the Catalog item a relevant name
...
(In the example, the name is James Model
...
)
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.
Ensure the
...
“Value Definition” is set to Enum and the name of the Enum that was just created. (In this
...
example: JamesAnimationsEnums)
Save the Catalog
...
Storyflow Script to Test
Create a new Storyflow
...
...
Frame Setup
Add the
...
Character from your Named Object catalog into the Resources section of the Frame. This will appear as a Scene Object Resource in your
...
Script (in the example
...
: James Animated
...
)
Click the + button on Main Frame to create another child
...
Frame
Name the
...
FrameBehaviour Models
...
Add a Behavior Model Resource to the Frame
...
Select the Scene Object as the Target
...
(in this example: Animated James
...
)
Add the Behaviour Model that was created in the previous step
...
(in this example: James Model
...
)
A drop down menu will now be visible with the name of the State above it
...
(In
...
this example
...
: JamesAnimationState
...
)
Click the + button next to the drop down field to create a
...
Give the
...
Variable a name and click the checkmark button
...
Create a new child
...
Frame
Add a Screen Message Resource (Playable Content type)
Enter Animation Test for the Title and Close this message to Animate for the Message field
...
Select the Event Link Shortcut (blue button with a white +) at the bottom of the Screen Message Resource and select
...
“Close”
In the new
...
Frame, add the Variable that was created earlier into the
...
Frame
Assign it the name of one of the animations from the drop down menu. This list displays the enum items which we created earlier
...
(In the example
...
= Stand-Gesture-Up_01
...
)
Save the
...
Script
...
...
...
Save the Scenario
Unity or VR Headset - Run the Storyflow Test Script
Run the
...
Scenario linked to the
...
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
Open the Animation Controller which is assigned to the Character
...
Delete the transition that goes from Stand-Gesture-Up_01 to Stand_Idle_01
...
Add an additional Animation. We will use Stand_NodYes_02
...
Create a transition from Stand-Gesture-Up_01 to Stand_NodYes_02
...
On this transition, we want
...
“Has Exit
...
Time” to be checked
...
Create a transition from Stand_NodYes_02 to Stand_Idle_01
...
On this transition, we want
...
“Has Exit
...
Time” to be checked
...
Save
...
In the Hierarchy, select the character
...
In the Animator component, click the
...
“Update Behaviour Model
...
File” button
...
Save the project
...
Unity or VR Headset - Run the Storyflow Test Script
Run the same
...
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.