How to play animation clip after the conditon is finished?

i have 2 animation clip, the first one plays automatically and the dialog box plays in timer.

so how do i play the second animation when the dialog box ended, i marked the location down below in the codes.

i really dont know the code for this one. i searched for days so being desperate i came here.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TextBox : MonoBehaviour {
	public GameObject textbox;

	public Text thetext;

	public TextAsset textfile;
	public string[] textline;

	public int currentline;
	public int endline;


	void Start() 
	{
		if (textfile != null) 
		{
			textline = (textfile.text.Split('

'));
}
if (endline == 0)
{
endline = textline.Length - 1;
}
}

	void Update () 
	{
		thetext.text = textline [currentline];

		if (Input.GetKeyDown (KeyCode.Space)) 
		{
			currentline += 1;
		}
		if (currentline > endline) 
		{
			textbox.SetActive (false);
                    //IM GOING TO PUT THE CODE HERE
		}
	}
	public void ReloadScript(TextAsset thetext)
	{
		if (thetext != null) 
		{
			textline = new string[1];
			textline = (thetext.text.Split('

'));
}
}
}

I’m not so sure about individual animations clips, but you could create an Animator Controller with the Animation clips inside. You can then use animation transitions with bools in the animator to set up the transition to the new animation. You could then use Animator.SetBool to set the bool from the animator to true.


69296-screen-shot-2016-05-03-at-83048-am.png
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

 public class TextBox : MonoBehaviour {
     public GameObject textbox;
 
     public Text thetext;
 
     public TextAsset textfile;
     public string[] textline;
 
     public int currentline;
     public int endline;

     public Animator anim;
 
     void Start() 
     {
         if (textfile != null) 
         {
             textline = (textfile.text.Split('

'));
}
if (endline == 0)
{
endline = textline.Length - 1;
}
}

     void Update () 
     {
         thetext.text = textline [currentline];
 
         if (Input.GetKeyDown (KeyCode.Space)) 
         {
             currentline += 1;
         }
         if (currentline > endline) 
         {
             textbox.SetActive (false);
             anim.SetBool("Variable", true);
         }
     }
     public void ReloadScript(TextAsset thetext)
     {
         if (thetext != null) 
         {
             textline = new string[1];
             textline = (thetext.text.Split('

'));
}
}
}