Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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.

Characters and Animation Controllers and Storyflow.mp4

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.

    • In the example, this is AnimatedJamesController.

  • 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.

    • To start, 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 and 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.

    • 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

  • Add an item to the catalog. 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.

  • Under Space Enums, enter a name into the New Enum Name field and press Enter. The example calls it JamesAnimationsEnum.

  • 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 catalog.

  • Add an item to the catalog and give it 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 case, the name is JamesAnimationsEnums.

  • Save the Catalog.

Storyflow Script to Test

  • Create a new Storyflow script

  • Name the first child 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, this is James Animated.

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

  • Name the frame Behaviour Models.

  • Add a Behavior Model Resource to the Frame.

  • Select the Scene Object as the Target.

    • In the example, this is Animated James.

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

    • In the example, this is James Model.

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

    • In the example, this is JamesAnimationState.

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

  • Give the variable a name and click the checkmark button.

  • Create a new child frame and add a Playable Content → Screen Message.

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

  • Select the 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, we use Stand-Gesture-Up_01.

  • Save the script

  • Assign the script to a scenario and 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.

  • No labels