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
-1
Question by mynameisjun · Jan 01, 2018 at 06:50 AM · animatoranimator controllerorder-of-execution

animator controller setTrigger problem

hey guys i have simple and annoying problem i just wanna animate my character to specific movement in specific moments but i doesn't seem to work my code here, very simple

 animator.SetTrigger("Idle")
 animator.SetTrigger("Run");
 

if it execute itself, character should animate as "Run". but it is actually "Idle" i have no idea what's going on here. maybe it happens by the particular properties of each anim?? here is the my anims info alt text

untitled.png (29.8 kB)
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 Prastiwar · Jan 01, 2018 at 09:11 AM 1
Share

You should put whole code, not only trigger - we know how trigger looks like. We don't know where and how did you put the trigger in your script.

1 Reply

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

Answer by Pinkuboxu · Jan 01, 2018 at 08:56 PM

I think I would need to see the whole context of where you are using the code. But my guess is that you aren't using Animator.ResetTrigger() to turn the one you aren't using off.

So, something like this maybe(?):

 // when you want to idle
 animator.SetTrigger("Idle");
 animator.ResetTrigger("Run");
 
 //when you want to run
 animator.SetTrigger("Run");
 animator.ResetTrigger("Idle");

I would probably need to see the full context to help anymore though.

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 Lysander · Jan 01, 2018 at 09:34 PM 1
Share

Triggers are automatically consumed and reset as soon as the next transition occurs, so really the only time it's necessary to reset triggers manually in this way is if one part of a script decides to trigger one animation, while another part (in the same frame) decides to override that command and trigger something else entirely. While it's possible that's happening here, my advice would be to advocate conditional trees and only firing the trigger that's actually needed for the task at hand ins$$anonymous$$d.

Not saying you're wrong exactly, but that controlling an animator is far cleaner when people forget that ResetTrigger even exists. $$anonymous$$ore info on this problem is definitely needed to give a solid answer I think.

avatar image Pinkuboxu Lysander · Jan 02, 2018 at 08:31 AM 1
Share

Well, I don't $$anonymous$$d being wrong. Being wrong is one of my favorite things because I learn a lot from being wrong and making mistakes. The $$anonymous$$iss Frizzle $$anonymous$$ethod. That's one of the reasons I've started trying to help on Answers because I can make suggestions and get corrected if I'm not correct, either way I'm part of being helpful. Even if I'm wrong, it stands as a means to show others what not to do. I'm not so much interested in pride as I am progress.

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

82 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

Related Questions

spawns without controller-: Object reference not set to an instance of an object--but i swear it is! 1 Answer

Animations don't work with humanoid avatars 0 Answers

blend tree animation through script? 0 Answers

Get back to non-animated type of the character while animating. 0 Answers

How do I check, and change, the current frame/time of a sprite animation in Unity 4.3? 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