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 Harpnart · Dec 06, 2015 at 09:07 PM · animationjavascriptanimatoranimation controllerinput.getkey

Animation state constantly being run, how to work around this?

I'm having an issue with my player controller where I'm constantly triggering an animation state. For example, if I'm holding down W, the up animation state will be triggered but since I'm holding down the button, the state is constantly being run without completing the animation so all I'm seeing is the first frame. I tried to use Has Exit Time which partially fixed it but there is lag between switching animations since the previous animation has to complete before moving to the next state.

In function Update() :

 if (Input.GetKey('w'))
         {
             playerRigidBody.velocity.y = speed;
             animator.SetBool("isUp", true);
         
         }
         else if (Input.GetKey('s'))
         {
             playerRigidBody.velocity.y = speed * -1;
             animator.SetBool("isDown", true);
         }
         else{
             playerRigidBody.velocity.y = 0;
             animator.SetBool("isUp", false);
             animator.SetBool("isDown", false);
         }
Comment
Add comment · Show 5
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 vintar · Dec 06, 2015 at 09:10 PM 0
Share

Try use Get$$anonymous$$eyUp ins$$anonymous$$d and so it will only be fired once on key up.

avatar image Harpnart vintar · Dec 06, 2015 at 09:28 PM 0
Share

The problem with that is the character will only be moved by a mm since the last else statement is run

avatar image vintar · Dec 06, 2015 at 09:30 PM 0
Share

I still don't get why it restarts the animation. Probably you do not have the animation set to "Loop" when it should be. Or you have the incorrect return transition set.

avatar image Harpnart vintar · Dec 06, 2015 at 09:41 PM 0
Share

I have Loop Time checked off for all the animations. I think the reason the animation restarts is because the trigger variable is always true so the animation state is triggered constantly

avatar image vintar · Dec 06, 2015 at 09:57 PM 0
Share

It shouldn't constantly be triggered because according to your code you use a Bool and not a trigger. The only reason I can see is if you have "True" set or both "in" and "out" transitions. Or somewhere else in your code it is being reset to false

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Harpnart · Dec 07, 2015 at 08:39 AM

I just realized there is an option called "Can transition to self" ._.

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do I animate a 2D sprite? 1 Answer

Precise animation control 4 Answers

Display additional animation on top of other animations 0 Answers

Mirroring animation clip without mirroring root motion node? 0 Answers

How to nest Animation file in an Animation Controller? 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