Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity call function on animation finish

// 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 :: Net.ServicePointManager.SecurityProtocol .net framework 4 
Csharp :: badlion 
Csharp :: c# xor byte array 
Csharp :: camera follow script car unity 
Csharp :: c# sort array of objects 
Csharp :: increment operator c# 
Csharp :: connection string in asp.net with username and password 
Csharp :: remove all non alphabetic characters from string c# 
Csharp :: project mongodb c# 
Csharp :: how to stop animation unity 
Csharp :: c# string code ascii 
Csharp :: validating file upload asp.net core mvc 
Csharp :: c# get application root path directory 
Csharp :: c# performance timer 
Csharp :: length of array c# unity 
Csharp :: c# string interpolation 
Csharp :: Convert DataTable to Dictionary in C# 
Csharp :: parent unity 
Csharp :: c# linq distinct group by nested list 
Csharp :: array of strings by splitting lines c# 
Csharp :: generate random dark colors programatically in android 
Csharp :: how to deserialize string array in c# 
Csharp :: ternary operator in c# 
Csharp :: IHttpContextAccessor 
Csharp :: c# right function 
Csharp :: how to find the tag of an objecdt in unity 
Csharp :: c# string ends with 
Csharp :: msbuild publish to folder command line .net 
Csharp :: bsod screen c# 
Csharp :: c# loop xml 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =