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 :: callback function on animation end unity 
Csharp :: what is type unity 
Csharp :: add variable to the beginning of a list c# 
Csharp :: how to create a random vector2 in unity 
Csharp :: how to add item in list at first position c# 
Csharp :: jagged array c# 
Csharp :: No migrations configuration type was found in the assembly 
Csharp :: c# bitmap to array byte 
Csharp :: check if string variable contains only letters c# 
Csharp :: LINQ query to select top 5 
Csharp :: instantiate unity in parent 
Csharp :: unity ihandler click right button 
Csharp :: C# add two numbers using a method 
Csharp :: c# enum default 
Csharp :: Replaced OS is obselete 
Csharp :: How can I return image from controller asp.net 
Csharp :: get file extension in c# file upload 
Csharp :: convert xml string to file c# 
Csharp :: declare dictionary c# 
Csharp :: c# get certain character from string 
Csharp :: How to catch Entity Framework Errors C# 
Csharp :: update listbox using class c# 
Csharp :: c# datetime for filename 
Csharp :: c# video to frames 
Csharp :: how to append something to a string in c# 
Csharp :: unity post processing on UI 
Csharp :: how to add rigidbody in unity 
Csharp :: dictionary string list int c# 
Csharp :: Write text in Word Document at specific location using C# 
Csharp :: meaning of ??= in c# 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =