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 /
  • Help Room /
avatar image
1
Question by BMD2018 · May 06, 2018 at 09:06 PM · animationbuttonanimatorplayfinish

How to let animation play to the end before playing the next one using button

ABSOLUTE BEGINNER...

I know this question is been ask 100.000 times, but i cant get it to work.

Please see my setup and be so kind to help me out with this...

Project:

Right now my animations with buttons run perfect. The animations are looped and on press the next animation starts, perfect!

BUT.... the animations do not play to the end, on pressing the button, the next animation begins, without waiting for the running animation to play to the end.

Here is the code:

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class FISH_ANIM : MonoBehaviour { private Animator Anim;

// Use this for initialization void Start() { Anim = GetComponent();

}

// Update is called once per frame

void Update() { }

public void Anim_turn_to_cam() { Anim.Play("Turn_to_cam", -1, normalizedTime: 0f); }

public void Anim_move_front_cam() { Anim.Play("Move_front_cam", -1, 0f); }

public void Anim_move_away_from_cam() { Anim.Play("Move_away_from_cam", -1, 0f);

}

}

what should i write after line e.g. :

Anim.Play("Move_away_from_cam", -1, 0f); .....

(yield did not work or i failed)

Thank you so much....

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · May 06, 2018 at 09:16 PM

Good day.

You have the bool isPlaying, which will be true during animation, and false once the animation has finished

Bye!

Comment
Add comment · Show 4 · 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 BMD2018 · May 07, 2018 at 08:37 AM 1
Share

Thanky you so much for your reply tormentoarmagedoom,

I think i did something wrong, here is my screenshot. Bool is not working.

When i press the button, animation is not playing to the end :(alt text

unity-animation-play-finished.jpg (366.3 kB)
avatar image tormentoarmagedoom BMD2018 · May 08, 2018 at 08:17 AM 0
Share

Hello again!

Look at your image, at the inspector, you have a timeline of 2 animations called "move in front" and "turn away". From second 2.5 to second 5 is trying to execute both animations at same time... of course is not possible, the blue zone is what you really will see, so now, the "front in move" animation finishes at 2.5 seconds...

$$anonymous$$ove the "turn away" animation to the right!

Bye! :D

(Accept the anseert if helped) :D

avatar image BMD2018 · May 08, 2018 at 07:45 PM 0
Share

Hi tormentoarmagedoom! Thank you again!!

I moved the clip as you said.

The "move_in_front_of_cam" clip is looping perfect, but when i click the button the next animation starts immediately without waiting for the clip "$$anonymous$$ove_in_front_of_cam" to play to the end.

Any other ideas?

When i click on the button, the clip should play to the end before the next animation starts.

Greetings...

avatar image tormentoarmagedoom BMD2018 · May 09, 2018 at 07:47 AM 0
Share

Good day :D

I'm not expert with animations, you should take a look at some youtube tutorial, I'm sure the answers is out there! Take your time, and explore... is always the best option! aAnd sure will learn more thing you didnt expected.

avatar image
0

Answer by BMD2018 · May 10, 2018 at 07:56 AM

Dear Unity Team,

can anybody help me out with this? I do not get it to work...

Please...

Comment
Add comment · Show 2 · 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 tormentoarmagedoom · May 10, 2018 at 11:47 AM 0
Share

Dear B$$anonymous$$D2018 we are not unity $$anonymous$$m, we are users like you :D and you have thousands of manuals and tutorials aboput animations! go spend some hours learning!

avatar image BMD2018 tormentoarmagedoom · May 10, 2018 at 02:38 PM 0
Share

Dear tormentoarmagedoom,

thank you for your reply.

God knows ive spend hours for this to get it to work. I watched all tutorials of this theme.

$$anonymous$$ost write the idea, but not the working code.

In Unity is this a solution:

animation.Play( ); yield return new WaitForSeconds( animation.clip.length );

but i am not a coder and C# is like chinese for me and i don't get it to work.

I haven't thought that this basic stuff is that complicated for me and to get help.

But thank you so much for your try.

Best regards,

B$$anonymous$$D2018

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

289 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 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

Cannot apply indexing with [] to an expression of type 'Animator' 1 Answer

How can I animate a button that is a child of a canvas? 1 Answer

Play animation on collision 1 Answer

Unity Animation OnStateExit doesn't work when i add conditions 0 Answers

Proper way to implement animations 0 Answers


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