Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity call function on animation onstateexit

// 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 :: what is type unity 
Csharp :: c# get list of all class fields 
Csharp :: read excel to object c# 
Csharp :: wpf mouse over style trigger 
Csharp :: set request timeout c# 
Csharp :: how to convert date to Complete ISO-8601 date in c# 
Csharp :: csharp datagridview filter column 
Csharp :: c# thread 
Csharp :: asp.net core get previouse url 
Csharp :: c# convert double to int 
Csharp :: Pass Querystring in C# httpclient 
Csharp :: array sorting c# 
Csharp :: c# select first value from list 
Csharp :: C# program that joins List of strings 
Csharp :: unity find object by name 
Csharp :: build cs file 
Csharp :: c# remove rows from datatable 
Csharp :: creating a streamwiter file C# 
Csharp :: how to make button in asp.net to go to other page 
Csharp :: or in if statement c# 
Csharp :: getter setter c# 
Csharp :: multi line comment c# 
Csharp :: c# run batch file 
Csharp :: contains duplicate 
Csharp :: C# network traffic 
Csharp :: c# how to set string list 
Csharp :: convert int32 
Csharp :: c# wpf get clipboard text 
Csharp :: Reverse Coding Challenge 1 
Csharp :: unity unfreeze position in script 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =