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
0
Question by KingKongFu · Nov 18, 2012 at 07:25 PM · animationinputyield

Yeild Problems

Im trying to let this animation play before pausing the game and allowing a user to chose between two options. What is happening the game freezes before the animation plays then unfreezes once the player choices the option they want. Im a bit lost on this it looks right to me but i have the foggest idea how to fix this Thanks for any help with this.

Ok so i made alot of changes to the code but now it wont get out of the If statement This is where its getting stalled at other wise its working fine

     if(sliderError && !onGround)
     {
         
         sliderDeploy();
         
 
         //make the choice
         if(Input.GetKey(KeyCode.A))
             { 
                 
                 Debug.Log("A was pressed");
                 sliderError = false;
                 deploy = true;
                 
                 
             }
     }



This is the new sliderdeploy finction function sliderDeploy() { this.animation.CrossFade("SliderHang"); //yield WaitForSeconds(2); this.rigidbody.drag = 0.9f; yield WaitForSeconds(2);

     if(sliderError)
     {
         Time.timeScale = 0;
         SliderError();
     }else
     {
         Time.timeScale = 1;
     }
     
 }


and here is where ity turns on and off the guitexture

 function SliderError()
 {
     //show ppic of error sugestions
     if(sliderError)
     {
         errorSelection.enabled = true;
     }else
     {
         errorSelection.enabled = false;
         
     }
 }
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 fafase · Nov 18, 2012 at 07:29 PM

Do not setTime.timeScale to 0,you are freezing the game. Instead, wrap up everything you want to stop in an if statement or wait for the animation to be done to set timeScale to 0.

Somehow:

 yield WaitForSeconds(animation["name"].length);
 Time.timeScale = 0.0f;

or

 while(animation["name"].isPlaying)return;
 Time.timeScale = 0.0f;
 

Obviously all of that needs to be in a coroutine.

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 KingKongFu · Nov 18, 2012 at 10:17 PM 0
Share

thanks that helped me weed out some of the problems

avatar image whydoidoit · Nov 18, 2012 at 10:31 PM 0
Share

Also check out this article on common challenges with this kind of thing.

avatar image fafase · Nov 19, 2012 at 06:46 AM 0
Share

The idea behind is that timeScale rules the speed of your game, everythng in the FixedUpdate or using deltaTime as well as the animation are affected. Only the mouse and Gui are still able to act. That is why your animation was waiting but you could still start the game again.

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

11 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

Related Questions

How to fix this problem? ios touch screen? 1 Answer

help with yield function 2 Answers

Play half of Animation on KeyDown/Other Half on KeyUp 1 Answer

Can the animation editor create local rotational data? 3 Answers

Can you use the physical hololens buttons as input to a Unity program? 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