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 Henri 1 · Apr 12, 2011 at 10:09 AM · animationcoroutineanimationsgetbuttondown

Cannot get animation to play until finish without holding down the button

Hi there,

Have a little problem with playing animations and CoRoutines....

When I press the applicable key, the character is suppose to taunt, but the animation does not completely play.

Have a script for my character to taunt as follow:

function COtaunt () { var state : AnimationState = animation[taunt1]; animation.Play("taunt1"); yield new WaitForSeconds (state.lenght); animation.CrossFade("idle"); }

function Update () { if (Input.GetButtonDown("Fire1")) { StartCORoutine("COtaunt"); } }

But, the CoRoutine does not complete, it only plays the first few frames (aprox 3) of the animation. I changed the Input.GetButtonDown to Input.GetButton, and it works, only problem is that you are not suppose to hold the key down to do the taunt. You must press it once, and then the animation must play.

I even tried to do:

function Update () {
  if (Input.GetButtonDown("Fire1")) {
    animation.Play("taunt1");
  }

But the animation still does not complete.....

I'm sure that I'm missing something simple, but tried all I could find in the Scripting Reference which I know about, and nothing fixed this.

Also, I want to block any other animations while its playing, and found the following:

private var InTransition : boolean = false;

and in the CORoutine I tried:

InTransition = true;

at the beginning, and at the end:

InTransition = false;

but it does not work. Aren't I suppose to add something to actually do something when the boolean is true?

Any ideas would be appreciated :)

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
0

Answer by Taran0 · Jul 05, 2011 at 03:23 PM

have you tried to set the animation to play once by changing the wrap mode

animation["taunt1"].wrapMode = WrapMode.Once

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 Henri 1 · Jul 07, 2011 at 07:55 PM 0
Share

Project abandoned... Thanks for your help though...

avatar image Dreamblur · Jul 07, 2011 at 08:13 PM 1
Share

It was prolly because you misspelled length.

avatar image Henri 1 · Jul 08, 2011 at 09:22 AM 0
Share

Hi Dreamblur, It could have been, not to sure, I typed the code when I asked the question, didn't copy and paste... But thanks anyways, will go back and check :)

avatar image CG-DJ · Apr 15, 2013 at 09:03 PM 0
Share

I'm having the exact same problem! AND yes I have it set the wrap mode to Once! WHAT IS GOING ON???

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 playing correctly 1 Answer

Integrating unitysteer with mixamo animation scripts 1 Answer

Animation precision is lost for character's blinking 1 Answer

function behaves unexpectedly inside a coroutine. 2 Answers

Problems with an animation 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