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 ez06 · Jun 03, 2014 at 12:16 AM · animations

Why are my animation transitions not always working?

I have several animations linked to my prefabs (which are enemy characters). My animations are for "Running" and "Idle".

For about half of my prefabs, even when the enemy stopped, the "Running" animation is still playing. For the other half, it transitions to "Idle" as it's supposed to.

Why is that happening? Why are some of the prefabs behaving erratically? Can it be linked to the fact that all my physics (and the whole script) are in Update() instead of FixedUpdate()?

Thanks in advance

Comment
Add comment · Show 4
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 meat5000 ♦ · Jun 03, 2014 at 12:37 AM 0
Share

Don't place Physics in Update()

Are you using Animator ($$anonymous$$ecanim) or Animation (Legacy)?

If the former, separate you Controller Script from anything else and force-feed it. $$anonymous$$eeping it trim keeps it responsive.

$$anonymous$$ake sure you setup Transitions properly; sounds like you animations are playing through to the end of the loop.

avatar image ez06 · Jun 03, 2014 at 12:57 AM 0
Share

Hi there, thanks for your response.

I'm using Animator.

What is "Controller script"? Do you mean the part which has "SetBool("Running",false) ? Also what do you mean by "force-feed it"?

Thanks a lot

avatar image ez06 · Jun 03, 2014 at 01:43 AM 0
Share

Thanks a lot for your explanation. Feel free to submit it as an answer.

avatar image meat5000 ♦ · Jun 03, 2014 at 01:46 AM 0
Share

Aye why not.

The last two sentences are probably the bits that do it :P Hope you haven't jumped the gun on accepting the answer :P

Leave a comment if you have further trouble.

1 Reply

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

Answer by meat5000 · Jun 03, 2014 at 01:16 AM

Yes that's the one.

I use my Controller Script as a barebones interface. Nothing else resides inside this script other than the logic to make my Animations run and a few variables, which I expose for use by other scripts. I use these other scripts to Push values to these variables via GetComponent; so Force-feeding.

For example

 var joystickInput : Vector2 = Vector2(0,0);
 
 //In Update()
 animator.SetFloat("walkFloat", joystickInput.y);
 animator.SetFloat("turnFloat", joystickInput.x);

This is all the code that is required to animate my character between 5 states of forward motion, 2 states of backward motion and blending with turn animations.

In this script 'joystick' is not actually connected to a Joystick. It is just a Vector2 that I am free to inject from other scripts. This means I can input values from any script, any controller or even take over the character control in some kind of event.

The Animation script remains very lean this way and so will always be responsive, never feel sluggish and never miss Animation triggers.

Do this and you are halfway there. The rest is making sure your Transitions are correct, in Animator and be careful with Exit Time parameter.

Also, If you set a Bool in animator, make sure to Unset it!

Comment
Add comment · Show 6 · 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 vipin8169 · Jul 23, 2015 at 04:18 AM 0
Share

While setting the SetBool("IsWalking",true) in the script, I can see that the checkbox for IsWalking gets checked in the Animator Window when I start walking, but still the animation for Idle keeps going on. Why is that?

avatar image meat5000 ♦ · Jul 23, 2015 at 11:03 AM 0
Share

SetBool("IsIdle",false); ?

You must clear previously set parameters which may interfere.

If you still have problems utilise the concept of animation layering and weighting to have the animator override the idle animation completely.

avatar image vipin8169 · Jul 24, 2015 at 03:22 AM 0
Share

There was no param by that time, issue was there was exit time associated with the idle animation.

avatar image meat5000 ♦ · Jul 24, 2015 at 11:14 AM 0
Share

It was an example :D Of course you should know what parameters you've used, there's no way I'd know without seeing your script!

It was supposed to re$$anonymous$$d you that if you set an idle parameter you must make sure to clear it when you want to enable something else.

Proper usage of Layer weighting can solve these issues also.

You must also make sure that there is a transition to the walking state available and that the conditions of your transitions are met.

This page links with the answer here.

avatar image Max_Bol · Jan 11, 2017 at 06:32 AM 0
Share

I know this is almost 2 years old, but it's one of the first result when looking up "unity animator transition condition not working" on google so it might be interesting for those who look it up.

With Unity 5.X, there's currently a bug with the Animator with the "State$$anonymous$$achine Default State". (Do not confuse it with the Default State. Default State is the orange node while the State$$anonymous$$achine Default State is the orange arrow.) Basically, the State$$anonymous$$achine DefaultState is only used when the State$$anonymous$$achine initiate itself through the $$anonymous$$ono Behavior.

A possible "fix" for the bug (whenever it happens) is to change the State$$anonymous$$achine Default State and return it back to the previous one. (To change hte State$$anonymous$$achine Default state, right click on the node that is before the one which ignore the parameters in the chain of nodes, then select "Set State$$anonymous$$achine Default State". Click on any other node than the default one. Repeat, but this this time, click on the one you really want as default.

Seems to be an issue with Unity's animation where the State$$anonymous$$achine Default State ends up with a infinite priority level which then ignore all parameters' based priorities.

avatar image drxmailman Max_Bol · Dec 10, 2019 at 04:33 AM 0
Share

To anyone who comes across this in the future, again this comment is 2 years after the last one, $$anonymous$$ax_Bol has hit the nail on the head. I have a complex (for me) animator controller which works perfectly fine but now its come time to add enemy AI's and Ive spent the past 45 $$anonymous$$utes trying to figure out what the hell I did differently and couldn't get the enemy to simply enter his animation state with just a bool parameter. Changing default animation state to something else and then back to Idle fixed it immediately.

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

24 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Help needed with scripting an enemy 0 Answers

how to make one script with different animations attached 2 Answers

Camera elements 2 Answers

Playing Animations? 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