Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by MrSteve1 · Apr 18, 2013 at 04:31 PM · animationisplaying

Animation Finished

Hey Guys,

I need some help with this one. I have an animation of one of my characters falling asleep, and another animation of them sleeping.

The problem I am having is I need to start the sleeping animation after the falling asleep animation has finished. I have tried using IsPlaying and PlayQueued but I can't seem to get it just right. Anyone have any ideas of some JavaScript that could help with this?

Thanks

P.S When will my questions and answers but posted without waiting for an administrator to approve it first?

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

1 Reply

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

Answer by LightSource · Apr 18, 2013 at 07:04 PM

Use yield WaitForSeconds if your desperate or just post your code and we will see what we can do.

20 karma is needed to post without moderator approval I believe.

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 MrSteve1 · Apr 18, 2013 at 08:41 PM 0
Share

I tried yield, it said it couldn't be a Coroutine. This is the Script I am using IGG (InGameGUI) refers to another scrip.

 function Sleeping()
 {
         sleeping = true;
         woddlArt.animation.Play("Snooze");
         zs.Play();
 }
 function Update()
 {
     if(IGG.sleeping && !sleeping)
     {
         move = false;
         woddlArt.animation.Play("Sleep");
         if(IGG.timer2 <= -35)
         {
             Sleeping();    
         }
         
     }

this way it kinda works, but its unreliable as it depends upon performance of hardware to look good.

avatar image LightSource · Apr 18, 2013 at 09:09 PM 0
Share

Yield cannot be used in an Update function because you can't halt the engine itself. $$anonymous$$ake a new function outside Update with the WaitForSeconds component and call that separately.

avatar image I Am The Minion · Apr 19, 2013 at 04:51 PM 0
Share

yield can only be used in a coroutine. something like:

  IEnumerator SleepDelay()
  {
       yield return new WaitForSeconds(2);
       woddlArt.animation.Play("Sleep");
  }

you call the function in update by using:

StartCoroutine(SleepDelay());

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

13 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

Related Questions

How can I read time from clip that is PlayQueued? 1 Answer

Check if multiple gameObjects play animation 2 Answers

Playing multiple queued animations in reverse 0 Answers

Play one animation after another... need help with Queued 1 Answer

How to check if an object is playing ANY animation 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