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
1
Question by WToa · Jan 16, 2015 at 07:55 AM · triggermecanimstate

Trigger the same state again?

I have a current setup where if you pick up an item, the animation is set to trigger on the UI Canvas to show "+10 Health!", it all works fine the first time, but afterwards I am unable to trigger it again when I pick up another item.

EDIT: Unity Version 4.6.1

The trigger is set by:

 healthanim.SetTrigger("HealthUp");

where healthanim is:

 GameObject.FindWithTag("HudCanvas").GetComponent <Animator> ();

If anyone has any thoughts on the matter it would be highly appreciated, I'm still new to Unity and trying to learn the ropes so if there is a better way to achieve what I am trying to do, feel free to suggest that too!

EDIT: My Mecanim Animation Thing alt text

animationmecanim.png (43.3 kB)
Comment
Add comment · Show 11
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 taxvi · Jan 16, 2015 at 08:55 AM 0
Share

why don't you use just an animation component for such simple animations. I mean, you don't have to switch states right? I don't have any suggestions about your problem tho... :/

avatar image GameVortex · Jan 16, 2015 at 09:05 AM 0
Share

This probably happens because your new AnimationState does not have a return transition back to the default where the trigger HealthUp is set to work.

avatar image WToa · Jan 16, 2015 at 09:11 AM 0
Share

@GameVortex I was using mecanim to handle the animation, and to my understanding a trigger should go back to the default? Or am I misunderstanding how triggers work?

avatar image tanoshimi · Jan 16, 2015 at 09:35 AM 0
Share

@taxvi The Animation component is deprecated. @WToa is correct to be using Animator.

@GameVortex There is a transition from "Any State" to "Health Up" (which we assume is linked to the HealthUp trigger), so it shouldn't matter that there is no transition back to default.

@WToa Play your scene with the Animator selected and you'll be able to see the transitions as they occur. Can you confirm what state the animator is in at the point the "Health Up" transition is no longer occuring? If it remains in the "Health Up" state, do you have the "Transition to Self" option enabled in the transition from Any State?

avatar image GameVortex · Jan 16, 2015 at 09:40 AM 0
Share

A transition can be activated by a trigger. When activated the current state transitions to the other state. How that state can transition to other states again depends on the transitions connected to it. You can activate the Trigger again but if no transitions in the state is listening to the trigger, nothing will happen.

But it does seem like you have a transition in the AnyState which is listening to the trigger? If that is the case then it should work. Have you looked at the animatorcontroller during runtime? You can easily then see which states and transitions are active. It might be that the state is actually activated but something else is preventing the animation to be shown properly, or maybe the code does not get to the SetTrigger function the second time. Try to add some debug.log to where you set the trigger.

Show more comments

1 Reply

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

Answer by tanoshimi · Jan 16, 2015 at 09:45 AM

Ah, I see :) Also, I believe that whether a state is allowed to re-enter itself is a behaviour that has possibly changed in different versions of Unity, so it would be helpful to know which version the OP is using. (discussed somewhat in http://forum.unity3d.com/threads/mecanim-any-state.158661/)

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 WToa · Jan 16, 2015 at 10:37 AM 1
Share

Thanks to @tanoshimi for showing me the solution.

Based on my problem, what you have to do is to check Enable Self Transition on the arrows leading out of Any State, the checkbox itself is shown here:

alt text

transitiontoself.png (31.9 kB)
avatar image Katori Nori · Jul 03, 2015 at 09:30 AM 0
Share

You saved my time!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Mecanim - Trigger event Invokation 0 Answers

Mecanim - Trigger event at end of animation state 4 Answers

Mecanim - changing animation clip speed, through script? 4 Answers

Mecanim - How to figure out the State and layerIndex that triggered Animation Clip Event? 0 Answers

How to get all states and state machines in the Animator on Android? 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