Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by MichaelJT · May 26, 2017 at 06:36 AM · animationtriggeranimator controllerbug-perhaps

Issues with Animator Controller - Trigger does not reset to false after being set with SetTrigger

Edit: Discovered a bit more about this issue. Apparently the issue is only occurring on the host. On the clients, this problem doesn't happen.

I still don't understand why it's getting triggered twice when it's only being triggered once.

Original Post:

I have been trying to solve this issue for a while now and I've eliminated a number of faults which could possible occur. In the animator, the trigger "attack" is set to true and stays true until the animation is called a second time, resulting in the desired animation playing twice instead of once like it should.

I understand that a trigger will stay true until it's used in the Mechanim animator, howeever it is used. It is used as soon as it is triggered, starting the first animation. Once the first animation is played, it then returns back to the idle state and the trigger starts the animation again, after which the trigger is set to false.

This isn't how it should be working and I'm currently stumped trying to figure out what is going wrong here. I'm currently using Unity 5.6.1p1.

 if (attack && !swinging) // Stops playing from starting a new attack when they're already attacking.
         {
             if (attackTimer >= attackRate)
             {
                 swinging = true;
                 attackTimer = 0f;
                 playerAnimator.SetLayerWeight(1, 1); // Set's the layer for attack animations to 1.
                 dealDamage = true; // Tells collision detection that damage can be dealt
                 canCombo = true;
                 networkAnim.SetTrigger(attackHash);
             }
         }

This code is what triggers my attack animation. Once setTrigger has been called, it cannot be called again until "swinging" has been set to false, which is done by checking the value of a curve attacked to the attack animation.

I have even changed my attack input from Input.GetButton to Input.GetButton down to ensure there is absolutely no possibility that the trigger is being set to true after the the animation has started, which was technically already being done by stopping the player from starting an attack when the bool swinging was already true.

I'm really at a loss to figure this problem out and I've read a tonne of posts from people having the same issues.

I've tried some of the solutions that people have offered but they haven't worked, and I'm slightly frustrated that I need to manually reset every trigger for every possible transition, when the whole point of a trigger is that once it's used, it automatically resets to false.

If anyone could assist me with this issue I'd be extremely greatful.

If I can't resolve this issue I'll probably start by rebuilding my animator controller from scratch, and if the problem reoccurs then I'm not sure what I'll do.

Comment
Add comment · Show 1
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 Bonfire-Boy · Aug 30, 2019 at 02:43 PM 0
Share

until "swinging" has been set to false, which is done by checking the value of a curve attacked (sic) to the attack animation.

Not sure I follow but since the trigger in question has "attack" in its name, perhaps is this saying that "swinging" gets set to false while the animation is still playing? If so then perhaps you're triggering again before the trigger has been consumed (I don't believe it gets reset until the end of the animation that it's triggered).

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Marshal_Alessi · May 26, 2017 at 07:30 AM

Not sure why you're experiencing the issue, but maybe try putting

networkAnim.ResetTrigger(attackHash);

in your update function, so that it resets it automatically. Hopefully this will fix your issue!

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 MichaelJT · May 26, 2017 at 08:15 AM 0
Share

Not really a solution to the problem at hand - more of a work-around.

I'm trying to figure out why the trigger isn't acting like it should in the first place.

avatar image
0

Answer by Pranky · Aug 30, 2019 at 10:31 AM

You can try following function

 void AnimTrigger(string triggerName)
  {
      foreach(AnimatorControllerParameter p in animator.parameters)
          if (p.type == AnimatorControllerParameterType.Trigger)
              animator.ResetTrigger(p.name);
      animator.SetTrigger(triggerName);
  }




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

161 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 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 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 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 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 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 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

Animation that is triggered with a ui button doesnt play on android build 1 Answer

How to smoothly change from opening a door animation to closing a door animation 0 Answers

How do I setup a Shooting Trigger to make an Animation play on a Platform? 0 Answers

Trigger not playing Animation 0 Answers

Animator Button Plus Transition 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