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 unity_LUbQ6QyiZDNLzQ · Mar 18, 2019 at 05:53 PM · animationbooleanbooldialogueondestroy

How to start animation after dialogue ends a.k.a currentLine == 3

So I have a dialogue and when it is finished (hits line 3) it is destroyed. I want to start an animation after the dialogue is finished. So basically it is character that player talks to and when the dialogue is finished the character runs away. This running away is an animation that I want to play after the dialogue is destroyed after hitting line 3. So basically I want to say animation true when hitting line 3 of the dialogue.

I have tried and failed, I might be missing something.

 public class ActivateTextAtLine : MonoBehaviour
 {
     public Animator animator2;
     public TextAsset theText;
     public int startLine;
     public int endLine;
 
     public TextBoxManager theTextBox;
 
     public bool destroyWhenActivated;
 
     // Start is called before the first frame update
     void Start()
     {
         theTextBox = FindObjectOfType<TextBoxManager>();
         if (theTextBox.currentLine == 3)                     //this should work ?
         {
             animator2.SetBool("PlayRun", true);
         }
     }
 
     // Update is called once per frame
     void Update()
     {
 
     }
     void OnTriggerEnter2D(Collider2D other)
     {
         if(other.name =="Player")
         {
             theTextBox.ReloadScript(theText);
             theTextBox.currentLine = startLine;
             theTextBox.endAtLine = endLine;
             theTextBox.EnableTextBox();
                 if (destroyWhenActivated)
             {
                 Destroy(gameObject);
             }
         }
     }
     void OnDestroy()     
     {
         
     }
 
     void OnTriggerExit2D(Collider2D other)
     {
                 theTextBox.DisableTextBox();
     }
 }





Comment
Add comment · Show 1
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 unity_LUbQ6QyiZDNLzQ · Mar 18, 2019 at 06:53 PM 0
Share

if I change theTextBox.currentLine == 3 to theTextBox.currentLine == 0 it works as expected at the current line 0, but somehow doesnt see the line 1,2,3 :///.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by highpockets · Mar 18, 2019 at 07:36 PM

You know that the code in your Start () method is only running one time, right? So it is likely == 0 at the beginning and that’s why the condition is true when you use 0 and not working for the other lines because the condition is not being checked.. You could put it in the Update () method to check every frame. Or you could start a coroutine and use a while loop (while currentLine < 3 for example) and start your run animation when the while loop returns false

Comment
Add comment · Show 3 · 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 unity_LUbQ6QyiZDNLzQ · Mar 18, 2019 at 08:22 PM 0
Share

I placed the same thing on update and still nothing ://

 if (theTextBox.currentLine == 3)                     //this should work ?
          {
              animator2.SetBool("PlayRun", true);
          }

avatar image unity_LUbQ6QyiZDNLzQ unity_LUbQ6QyiZDNLzQ · Mar 18, 2019 at 08:29 PM 0
Share

Ok, now I fixed it :D, so happy. turns out I had to swich to private Void update. I just dont know whats the difference between public and private except for the word meaning private and public. The dynamisc are unclear , but at the end it just works and it is good enought, thanks, can I make your comment as an answer ?

avatar image highpockets unity_LUbQ6QyiZDNLzQ · Mar 18, 2019 at 10:10 PM 0
Share

Just converted it to an answer. Thanks for asking glad it works

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

264 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Add a bool to animator & activate by key press 1 Answer

How to start animation after object is destroyed ? 0 Answers

multi animation by pressing one button ,Multi Animation 0 Answers

Animtor Stuck 1 Answer

Double collision on "ground" tagged object results in player thinking they're in air? 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