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 Mcdsnte · May 23, 2017 at 02:50 PM · 2d gameanimatoranimator controllertransition

Animator not switching states properly

My animator has a transition going from idle to walk called "State" and it goes from integer 1 and 2, but the darn thing won't shift to my walk animation unless I jump first and its a bummer to fight with this for so long.

Here is my :Player code containing the animator code: link text

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

3 Replies

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

Answer by jwulf · May 23, 2017 at 03:56 PM

2 comments and an answer:

  1. It's usually more useful if you copy code into your question (using the "101010"-Button above the input field) than post your code as a screenshot.

  2. It would usually be useful to see your animator configuration as well (here, a screenshot makes sense)

To your question, it is pretty obvious why you need to jump first, because you code is:

 if(Input.GetKeyUp(KeyCodeSpace)) {
     // ...
     if(Input.GetAxisRaw("Horizontal") != 0) {
         anim.SetInteger("State", 2);
     }
 }

So the Line

 anim.SetInteger("State", 2);

can only be reached in the very frame the Space-Key is released (see https://docs.unity3d.com/ScriptReference/Input.GetKeyUp.html) and since Space is appearantly your Jump-Key, it makes sense that you observe the Transition only happens after jumping.

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 Mcdsnte · May 23, 2017 at 04:16 PM 1
Share

Thank you very much!

avatar image jwulf Mcdsnte · May 25, 2017 at 07:57 PM 0
Share

You're welcome! :)

avatar image
0

Answer by thereturn998 · May 25, 2017 at 02:57 PM

Did you check your transitions in animator? If don't check if you have a transition from idle to walk that have integer condition. alt text

For example in this animator transitions while Joey_walking_up animation is active animation cant goes bak to idle animation directly but if it is idle it can walk up. Because transition is from idle to walking up not from walking up to the idle. I wish this answers you question.


animator.png (20.3 kB)
Comment
Add comment · Show 1 · 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 Mcdsnte · May 25, 2017 at 03:02 PM 0
Share

This extra information was useful . Thank you, but my issue was what what jwulf stated and its now fixed :)

avatar image
0

Answer by Mcdsnte · May 25, 2017 at 02:56 PM

@jwulf Thank you I was in such a rush to complete the code before my other plans came that I completely overlooked where the code was sitting. Thanks so much

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

unity animator transition keeps transitioning to beginning of animation 2 Answers

How to access and modify an animator state transition in runtime? 1 Answer

(Unity/Mixamo) Animation won't play all frames 2 Answers

Smooth transition of position between animations 0 Answers

Animation Running Game 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