How do I put a delay in this?

Hi, I have a problem with my code

                 if (Input.GetKeyDown (KeyCode.F)) {
		Player.SetTrigger ("Punch_Mid_Start");
	} else {
		Player.SetTrigger ("Punch_Mid_Finish");

		if (Input.GetKeyDown (KeyCode.G)) {
			Player.SetTrigger ("Special_Move_Start");
		} else {
			
			Player.SetTrigger ("Special_Move_Finish");
		}

So basically this is code for my fighting game and my special move. The animation plays half way through then jumps to idol.
So I want to put a delay between the special move start and finish so that the animation can finish then return to idol
I just don’t know how.

In the animator check to see that there is an exit time from the transitions, and set the exit time value to 1, that should fix your problem. :slight_smile:
@AWilliams5

I think you should start a coroutine and wait for the length of the animation to start the next one. The code below expects that the animation state is on the base layer. If it’s on a different layer, you would have to change it from 0 to whatever the correct layer index is.

Cheers

public Animator anim;

void Update(){


if (Input.GetKeyDown (KeyCode.F)) {
         Player.SetTrigger ("Punch_Mid_Start");
     } else {
         Player.SetTrigger ("Punch_Mid_Finish");
         if (Input.GetKeyDown (KeyCode.G)) {
             StartCoroutine(SpecialMove());
             
         }
}

IEnumerator SpecialMove(){
Player.SetTrigger ("Special_Move_Start");
yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length);
Player.SetTrigger ("Special_Move_Finish");
}