This Tutorial builds up on the graph created in Tutorial 2 - Basic Locomotion.
To trigger the new smoking state, a new input is needed. Since the default graph Setup already created an example Input, this can be reused.
Each legal value must be made known to the Animation Graph.
A new dialog window will open and ask for the new value this Input can have.
The new value has been added to the list of valid values in the Key Properties. It is now available for Selection in the Selection Criteria of States.
If Code, Console or Flowgraph tries to set an Input of the type Key to a string value that is not in this list, the value will be ignored and the input assumes the value listed as the DefaultValue in the Properties.
The last step to do is to set this new value in the Selection Criteria of the Smoking State.
Since the "Action" Input was created by the Graph automatically as a default, it has been assigned to the Idle state's Selection Criteria upon creation and set to "Any Value". Since this would interfere with the new state being selected, go into the Idle State's Selection Criteria.
When the graph switches animation states, it will try to find a path through the graph's links to the new state - and play any transition animation that is on the way.
The current graph only has states, it needs to have some links before it can pathfind and play transitions.
Since the new state is a transition animation, it is non-selectable and will appear yellow in the view. The graph will not actively select this state because it matches the Inputs well, it is only used along a path from one green state to another
All Locomotion States are now accessible through the "Locomotion Hub" state.
Hub States are a very practical way to route many states through the same path without creating an exponential amount of links. It is advisable to use them wherever possible. Since they are non-selectable states (yellow) they do not have a performance impact during state selection.
States can be placed in more than one view, since views are just a virtual separation to help keep things organized in the editor. This is useful especially with Hub states to link big amounts of states together without placing them all in the same view.
ag_reload_ag
on the console to hot reload the graph (or simply restart the editor) to make the changes become active.ag_debug 1
on the console to enter the debug mode for the hero's animation graph.Debug information about the active state and the input values is printed on the screen.
With the ag_action smoke
command, set the "Action" input value to the "smoke" value as set up in the graph.
This will also change the debug output on the screen.
You can see the character's current animation first lighting the cigarette and then entering the Smoke loop.
If you need to slow things down to follow the transition, use t_Scale
to slow down time.
To see the out-of transition just use the ag_action none
command to reset the Action Input again.