Skip to content

Instantly share code, notes, and snippets.

@softrare
softrare / NewStateMachineBehaviourScript.cs
Last active August 29, 2015 14:16
A mask for a state machine behaviour script in Unity3d (v5). Information taken from http://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours
using UnityEngine;
using System.Collections;
/*
* source: http://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours
*
* The core of state machine behaviours are 5 functions that are automatically called whilst in an animator state and 2 functions that are automatically called whilst in a sub-state machine.
* Commented out versions of some of these functions are added to new state machine behaviours when they are created. These functions are OnStateEnter, OnStateUpdate, OnStateExit, OnStateMove and OnStateIK.
* The additional functions for sub-state machine transitions are OnStateMachineEnter and OnStateMachineExit.
* All of these functions have 3 parameters passed to them: an Animator, an AnimatorStateInfo and the layer index