Makinom - Game Toolkit for Unity
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom

Guide

Getting Started

  • Introduction
  • First Steps
  • Game Starters
  • Components Overview
  • Upgrading a Makinom 1 Project

Editor

  • Makinom Editor Overview
  • Node Editor
  • Asset Sources
  • Editor Section
  • Base/Control Section
  • Game Section
  • UI Section
  • Templates Section

Features

  • Schematics
  • Dialogue Importer
  • Schematic Nodes
  • Formula Nodes
  • Languages
  • Input Keys
  • Audio and Music
  • Game States
  • Pooling
  • Saving Game Objects
  • Scene Objects
  • Save Games
  • Variables
  • Selected Data

Machines

  • Machine Components Overview
  • Animation Machine
  • Animation State Machine
  • Application Machine
  • Auto Machine
  • Collision Machine
  • Global Machine
  • Interaction Machine
  • Render Machine
  • Tagged Machine
  • Template Machine
  • Tick Machine
  • Trigger Machine

UI System

  • UI System Overview
  • UI Layers
  • UI Layouts
  • UI Boxes
  • HUDs
  • Flying Texts
  • Text Codes
  • Unity UI Module
  • HUDs: Content Providers
  • HUDs: Conditions
  • HUDs: Click Actions

Scripting

  • Scripting Overview
  • Code Extensions
  • Custom Save Data
  • Custom Component Save Data
  • Custom Nodes
  • Starting a Schematic

Advanced Topics

  • Build Troubleshooting
  • Performance Optimizations
  • Home
  • Guide
  • Documentation
  • Machines
  • Animation State Machine

Animation State Machine

Table of Contents
  • Start Types
    • State Machine Enter
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Machine Exit
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Enter
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Exit
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State IK
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Move
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Update
      • Local Start Variables
      • Additional Start Conditions
      • Example

Learn more about animation state machines and what you can use them for.

Animation state machines are Unity state machine behaviours that are added to animator states. They’re used in animator controllers, e.g. to react on state changes.

An animation state machine can be added to a state by selecting a state and clicking on Add Behaviour > AnimationStateMachineComponent.

You can learn more about machine components in general and their basic settings here.

Start Types #

An animation state machine is started by state machine and state change callback functions.

State Machine Enter #

Started when transitioning from another state machine’s state to the state’s state machine. It’s implemented in the component’s OnStateMachineEnter function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • stateMachinePathHash (int)
    Stores the full path hash of the state machine.

Additional Start Conditions #

The State Machine Enter start type can optionally check the state machine’s path hash the OnStateMachineEnter function was called with. This can be used to e.g. only start the machine when the path hash matches a defined value.

Example #

This start type can be used to change an animator parameter when entering a state machine. Use a Play Mecanim Animation node to change parameters of an animator.

State Machine Exit #

Started when transitioning from the state’s state machine to another state machine’s state. It’s implemented in the component’s OnStateMachineExit function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • stateMachinePathHash (int)
    Stores the full path hash of the state machine.

Additional Start Conditions #

The State Machine Exit start type can optionally check the state machine’s path hash the OnStateMachineExit function was called with. This can be used to e.g. only start the machine when the path hash matches a defined value.

Example #

This start type can be used to change an animator parameter when leaving a state machine. Use a Play Mecanim Animation node to change parameters of an animator.

State Enter #

Started when the state machine starts evaluating the state (i.e. when entering the state). It’s implemented in the component’s OnStateEnter function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • layerIndex (int)
    Stores the state’s layer index.
  • fullPathHash (int)
    Stores the full path hash of the state.
  • shortNameHash (int)
    Stores the path hash of the state.
    This hash is generated using Animator.StringToHash and doesn’t include the parent layer’s name.
  • tagHash (int)
    Stores the hash of the state’s tag.
  • length (float)
    Stores the current duration of the state.
  • normalizedTime (float)
    Stores the normalized time of the state.
  • loop (bool)
    Stores if the state is looping or not.

Additional Start Conditions #

The State Enter start type can optionally check the layer index the OnStateEnter function was called with. This can be used to e.g. only start the machine when called from a defined layer.

Example #

This start type can be used to play an audio clip when entering a state. Use a Play Sound node to play an audio clip.

State Exit #

Started when the state machine ends evaluating the state (i.e. when leaving the state). It’s implemented in the component’s OnStateExit function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • layerIndex (int)
    Stores the state’s layer index.
  • fullPathHash (int)
    Stores the full path hash of the state.
  • shortNameHash (int)
    Stores the path hash of the state.
    This hash is generated using Animator.StringToHash and doesn’t include the parent layer’s name.
  • tagHash (int)
    Stores the hash of the state’s tag.
  • length (float)
    Stores the current duration of the state.
  • normalizedTime (float)
    Stores the normalized time of the state.
  • loop (bool)
    Stores if the state is looping or not.

Additional Start Conditions #

The State Exit start type can optionally check the layer index the OnStateExit function was called with. This can be used to e.g. only start the machine when called from a defined layer.

Example #

This start type can be used to play an audio clip when leaving a state. Use a Play Sound node to play an audio clip.

State IK #

Started immediately before it updates the animator’s internal IK (inverse kinematics) system but after Animator IK, when the state is active and the state’s layer has an IK pass. It’s implemented in the component’s OnStateIK function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • layerIndex (int)
    Stores the state’s layer index.
  • fullPathHash (int)
    Stores the full path hash of the state.
  • shortNameHash (int)
    Stores the path hash of the state.
    This hash is generated using Animator.StringToHash and doesn’t include the parent layer’s name.
  • tagHash (int)
    Stores the hash of the state’s tag.
  • length (float)
    Stores the current duration of the state.
  • normalizedTime (float)
    Stores the normalized time of the state.
  • loop (bool)
    Stores if the state is looping or not.

Additional Start Conditions #

The State IK start type can optionally check the layer index the OnStateIK function was called with. This can be used to e.g. only start the machine when called from a defined layer.

Example #

This start type can be used to set the positions of the IK goals and their respective weights. Use an Animator Weight node to set the position and weight IK goals.

State Move #

Started each frame the state is active, after Animator Move. It’s implemented in the component’s OnStateMove function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • layerIndex (int)
    Stores the state’s layer index.
  • fullPathHash (int)
    Stores the full path hash of the state.
  • shortNameHash (int)
    Stores the path hash of the state.
    This hash is generated using Animator.StringToHash and doesn’t include the parent layer’s name.
  • tagHash (int)
    Stores the hash of the state’s tag.
  • length (float)
    Stores the current duration of the state.
  • normalizedTime (float)
    Stores the normalized time of the state.
  • loop (bool)
    Stores if the state is looping or not.

Additional Start Conditions #

The State Move start type can optionally check the layer index the OnStateMove function was called with. This can be used to e.g. only start the machine when called from a defined layer.

Example #

This start type can be used to move a game object based on root motion. Use a Store Parameter node to store parameters from the animator controller into variables and use them in one of the various Movement nodes (e.g. a Move node) to move the game object.

State Update #

Started each frame the state is active, except the first and last frame (i.e. when State Enter and State Exit are used). It’s implemented in the component’s OnStateUpdate function.

Local Start Variables #

This start type will automatically initialize the following local variables.

  • layerIndex (int)
    Stores the state’s layer index.
  • fullPathHash (int)
    Stores the full path hash of the state.
  • shortNameHash (int)
    Stores the path hash of the state.
    This hash is generated using Animator.StringToHash and doesn’t include the parent layer’s name.
  • tagHash (int)
    Stores the hash of the state’s tag.
  • length (float)
    Stores the current duration of the state.
  • normalizedTime (float)
    Stores the normalized time of the state.
  • loop (bool)
    Stores if the state is looping or not.

Additional Start Conditions #

The State Update start type can optionally check the layer index the OnStateUpdate function was called with. This can be used to e.g. only start the machine when called from a defined layer.

Example #

This start type can be used to play an audio clip when while being in a state. Use a Play Sound node to play an audio clip – additionally, you can check the local float variable normalizedTime (passed as start variable) to check the current play position of the state and only play the sound at specific points.

Machines
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on December 16, 2020
Table of Contents
  • Start Types
    • State Machine Enter
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Machine Exit
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Enter
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Exit
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State IK
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Move
      • Local Start Variables
      • Additional Start Conditions
      • Example
    • State Update
      • Local Start Variables
      • Additional Start Conditions
      • Example
Sitemap
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom
  • Contact
  • Blog
  • ORK Framework
  • gamingislove.com
Categories
  • Makinom 1 (97)
    • Tutorial (97)
      • 2D Platformer (14)
      • 2D Roguelike (8)
      • Breakout (6)
      • How-to (34)
      • Match 3 (6)
      • Schematic (4)
      • Scripting (6)
      • Space Shooter (11)
      • Survival Shooter (8)
  • News (11)
  • Release (68)
Search

© 2015 Gaming is Love e.U.

Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!