Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TeslaBazubaz · May 03, 2016 at 04:35 AM · animationanimatoranimationclipcondition

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('\n'));
         }
         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('\n'));
         }
     }
 }
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rober-psious · May 03, 2016 at 08:03 AM 0
Share

Who has the animation? The textbox gameobject? The same wich is using this class?

How do you handle the animation: via Animation or Animator component?

avatar image TeslaBazubaz rober-psious · May 03, 2016 at 09:54 AM 0
Share

the animation is on the other gameobject that holds camera.

i made it through Animation. the one with keys. so its a clip

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Halleester · May 03, 2016 at 01:59 PM

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. alt text alt text 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('\n'));
          }
          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('\n'));
          }
      }
  }



screen-shot-2016-05-03-at-84220-am.png (31.9 kB)
screen-shot-2016-05-03-at-83048-am.png (29.0 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TeslaBazubaz · May 04, 2016 at 01:44 AM 0
Share

thanks man, and i removed the exit time and it works perfectly well

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation not looping 1 Answer

Parameterized Animation Clip 0 Answers

Mirroring animation clip without mirroring root motion node? 0 Answers

Animator Override Controller changed at runtime doesn't always play the animations correctly 1 Answer

Why does my transition freeze the second animation on it's first frame? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges