Answers for "wait for animation to finish unity"

C#
8

wait time in unity

using System.Collections;

private void Start()
{
	StartCoroutine(Wait());
}

IEnumerator Wait()
{
	//To wait, type this:
  
  	//Stuff before waiting
	yield return new WaitForSeconds(/*number of seconds*/);
  	//Stuff after waiting.
}
Posted by: Guest on July-12-2020
0

unity wait for animation to finish

//if animation with name "Attack" finished

if (anim.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
{
	//do something
}
Posted by: Guest on September-08-2020
5

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
}
Posted by: Guest on April-21-2021

Code answers related to "wait for animation to finish unity"

C# Answers by Framework

Browse Popular Code Answers by Language