Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity call function on animation end

// 1. click on the animation state block in the animator and in the inspector
// 2. click Add Behavior button and edit that new script
// 3. find the OnStateExit function and un-comment it. Example below.

// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
  GameObject self = animator.gameObject; //a reference to the gameobject being animated
  MyScript script = self.GetComponent<MyScript>();
  Debug.Log("Animation has finished!");
  script.SendMessage("MyFunction"); //this is the name of the function to call
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: swap two numbers c# 
Csharp :: How to take input on float in c# 
Csharp :: unity action example 
Csharp :: c# get last 3 characters of string 
Csharp :: c# enum syntax 
Csharp :: operator -- c# 
Csharp :: how to add a gameobject 
Csharp :: play animation through script unity 
Csharp :: generate entity model dot net core 
Csharp :: unity health bar 
Csharp :: how to work with ascii in c# 
Csharp :: array sort c# 
Csharp :: variable gameobject unity 
Csharp :: windows form textbox password 
Csharp :: unity find object by name recursion 
Csharp :: c# execute shell command 
Csharp :: datetime check null c# 
Csharp :: c# remove word from string 
Csharp :: delete the particular line in files in c# 
Csharp :: c# set cursor pos 
Csharp :: mfind how many digits a number has c# 
Csharp :: .net core partial view with model 
Csharp :: unity how to destroy child 
Csharp :: C# clear console input buffer 
Csharp :: how to chceck for a tag in a trigger enter 2d unity 
Csharp :: c# csvhelper 
Csharp :: access object property C# 
Csharp :: c# regex find last match 
Csharp :: jenga db connection 
Csharp :: type or namespace text could not be found unity 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =