Introduction

Welcome to my little tutorial. We will recreate the example called XMasTest that it is including in source code. Our goal is simulate player ruing with pad and die when press A button, wait for animation end and then press A again to reviving.

Create animation graph

Launch the editor and select Model->Import new model. Load model Model/trooper/trooper.xnb. It's a compiled model that load immediately, if you load an exported cal3d model a Please Wait windows appears.
Model_Import.JPG

We always need a Start Node, let's create it, press on an empty area of editor with right button and select Start Nodes->Add AnimNode_Start
Add Start.JPG

Next we need a node that blend between our states, BlendList in our node. Press on an empty area of editor with right button and select Control Nodes->Add AnimNode_BlendList
Add Blend.JPG

Create a connection between start node and blend node, to do this simply drag the start node outgoing connector (blue one) to the blend list incoming connector (black).

We have three states planing, Alive, dead and reviving and our blend list only have one, we need to create two more. Right click on blend list child and select Add Child twice. Next we want to change the child description, right click on child and select Rename Child and change all names.
ItemNodes.JPG

The Dead and Reviving states are simples, add two Animation Nodes and connect with the two children. Remember if you want to move a node simply drag the node caption.
Add_Anim.JPG
Anim Nodes.JPG

To control blend between idle and run we need crossfade node, add it and connect first child (alive) with this node.
Add_crossfade.JPG

Create two more AnimNode_Animations and connect with new crossfade node. Now you have a graph like this
Nodes result.JPG

Change AnimationNodes properties

We need to set the animations. Let's change the animations of crossfade children. The first one is the idle. Select with left click and select the animation Idle in AnimName combobox on properties panel (left down)
ChanegAnimName.JPG
Do the same with second child but select the run animation. Note if you drag the Crossfade slider you can see the result blend in the model!

Let's change the other animation nodes, the dead and reviving children. Set the death animation on two nodes. And change Loop property to False and SendAnimEvent to true
DeathNode.JPG
We do this because we want this animations as transitions and we only want to play once and raise event to change our state

We need change the reviving rate. Set to -1, we want to play backwards!! and change node name to reviving. We want to change name because the OnAnimEnd event will send us the anim name, and node name and we will know who is the node that ends
revivinganim.JPG

Change reflexion properties

The way to communicate animation graph and code in XMas is by reflexion. We create a class use to store values that change with time and graph read this values and change the node weigh.
Each node type need a data value. The blend list wants the children index and crossfade wants a value between 0 and 1. You can see the wanted values by node in documentation.

Click on BlendList node and change Reflexion Property to State, change the name too. Changing name it's only visual, because change the caption too.
StateNode.JPG

Do the same with crossfade node. Change to Speed, reflexion property and name. Note that node have two more parameters Down Speed and Up Speed. Set two 2. All parameters have help, select parameter and look in help section on properties panel (down)
PropertyCrossFade.JPG

We almost finish, only save graph. To do this select File->Save from main menu.

To continue this tutorial see Code Tutorial

Last edited Dec 22, 2008 at 8:23 AM by Liaven, version 4

Comments

No comments yet.