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
2
Question by Dr_GeoFry · Jun 19, 2013 at 07:35 PM · animationmecanimtransitionparameters

Animation will not Return to Proper State

Hello everybody,

I have an issue that makes no sense to me. I am working on code for an enemy. All of my animations play as they should. However, once the enemy has begun his attack cycle, it will never return back to a non attacking state in its animation. This is especially odd because when I watch the animation cycle in the animator window, it shows that isAttacking is true while he attacks, and isAttacking is false when the player is out of range. But even while I am out of range, and isAttacking shows false, the enemy still stays in his attacking animations from that point forward.

I am wondering why the system knows that the enemy is not attacking (`isAttacking = false`) but the animation continues. I'm just unsure of where the problem is. The code is simple, thus it should be right. I set the boolean so that the animator transitions correctly into fighting and shows the checkbox as true once that state has been reached, but when I move beyond the appropriate attackDistance the enemy is stuck in his animation state, and does not return to walking or running or whatever I might want it to be.

Thanks for your assistance. I am hoping for possible brainstorming on this issue. I would provide code, but the relevant pieces are so simple that I don't think it is relevant. I was going to provide pictures, but the file size was too large. I'm more curious if this is an issue that people have come across before. And if so, how did they solve it.

Comment
Add comment · Show 15
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 pickle chips · Jun 19, 2013 at 08:05 PM 0
Share

No matter how simple the code, it will always help us answer. $$anonymous$$y guess is that once it is set back to false, nothing is telling it to play a different animation. It's hard to say though without seeing any code :p Posting it will help your question be answered faster

avatar image TonyLi · Jun 19, 2013 at 08:07 PM 0
Share

When you move out of range and the isAttacking animator parameter becomes false in the Animator window, what state is active in the Animator window? (i.e., what state has the little blue progress bar running in it?) $$anonymous$$aybe your script is setting the parameter correctly but the transition from attack-->idle state isn't triggering.

avatar image Dr_GeoFry · Jun 19, 2013 at 09:33 PM 0
Share

@ToniLi, it stays on attack... that is what is so mysterious and confusing. while it says isAttacking is false in the animator window, it continues playing the attack animation.

avatar image Sequence · Jun 19, 2013 at 10:26 PM 0
Share

Please provide a code sample, you might have overlooked something that someone else can spot!

avatar image Sequence · Jun 20, 2013 at 12:36 AM 0
Share

Ah, I see, this must be $$anonymous$$ecanim. Unfortunately I don't have any experience with it. I wish I could help though. I voted your question up though so hopefully someone else that knows mecanim will see it.

Show more comments

2 Replies

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

Answer by TonyLi · Jun 21, 2013 at 02:33 AM

In a transition, all conditions must be true.

The attack-->walk transition never fires because distance is never greater than 0.01. In Update(), just add this line:

     myAnimator.SetFloat("distance", distance);
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 Dr_GeoFry · Jun 21, 2013 at 03:58 AM 0
Share

thanks, @TonyLi all I had to do was change the parameter criteria from 0.01 to an appropriate distance that I liked. Thanks again to everybody that offered help and brought me closer to the successful conclusion of this problem.

avatar image
0

Answer by Ben-Stoneman · Jun 20, 2013 at 12:49 PM

When the player is out of range of the enemy then nothing stops the animation "attack" from playing.

When the player is out of range of the enemy have it check whether to peruse the player or go idle and start the animation depending on the result.

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

18 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

Related Questions

Combining two animations to be one 0 Answers

Mecanim mysterious curve 2 Answers

Mecanim Root Motion Rotation - 180 degree turn. 2 Answers

Mecanim transition between animation help 0 Answers

Mecanim won't save instant transition 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