• 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 /
This question was closed Apr 19, 2016 at 10:54 AM by JustMax for the following reason:

The question is answered, right answer was accepted

avatar image
Question by JustMax · Jan 13, 2015 at 11:38 AM · animatorbugmecanimanimator controller

Mecanim "trigger" parameter behaviour with multiple animator layers

Hi, everybody.

I've noticed a strange behaviour of mecanim's "trigger" animator parameter.

Let's say I have an animator controller with multiple layers and a trigger parameter defined in t$$anonymous$$s controller. T$$anonymous$$s trigger is used to perform transitions on different layers. Moreover, t$$anonymous$$s transitions can and should be performed simultaneously. E.g. when setting "walk" trigger character should stop suffering animation (w$$anonymous$$ch is on the layer with index, 2) and start walking (layer with index 1). So the problem is: transition on $$anonymous$$gher layer (i.e. with $$anonymous$$gher index) can never be fired. If the transition on lower layer is performed too fast, the trigger will be reset before $$anonymous$$gher layer even start its transition. T$$anonymous$$s can happen if Time.timeScale value is big (I reproduced with timeScale equals 3), or if you set some triggers right after another.

I've implemented some sort of triggers queue to handle t$$anonymous$$s strange behaviour in case of multiple triggers set one after another. But cannot t$$anonymous$$nk up anyt$$anonymous$$ng to fight with timeScale.

Actually, I t$$anonymous$$nk, that some kind of triggers queue (synchronized with multiple layers) should be implemented internaly in Mecanim, it would be a much more intuitive for usage.

So the first question is: Why Unity implemented such behavoiur of triggers?

The second one: Any suggestions how to cope with timeScale issue.

Comment
Raresh

People who like this

1 Show 2
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 Baste · Jan 13, 2015 at 12:25 PM 1
Share

This is definitely strange. I assumed that every active state in every layer was informed about each trigger fired.

How to fix this? Well, I tend to stick to bools rather than triggers anyways, and they won't suffer from this problem. So that's my suggestion - build your system around booleans.

The reason for why I'm already doing this is that with triggers, I kept introducing bugs related to timing, where triggers were not consumed when I sent them, and idled in the system until I passed by a state that could consume that trigger. Your issue gives me another reason for why I'll do this.

Not posting this as an answer as it's not really an answer, it's a work around.

avatar image JustMax · Jan 13, 2015 at 12:38 PM 0
Share

I've though up couple of workarounds for this.

The first, which I liked more, is hand-made triggers system (as you suggested). But this is quite hard task, if you want to make maintainable module (and actually I don't have enough time for this right now). This solution, nevertheless, can solve the problem completely.

The second solution: duplicate triggers and make connected set of triggers (fast but hard to maintain for big animator controllers).

And the third one (which I ended up with): setup transitions more precisely. It fixes my problem but it's not universal.

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by JustMax · Jan 19, 2015 at 02:09 PM

http://unity3d.com/unity/whats-new/unity-4.5.5

Here is said: "Mecanim: Fixed trigger parameter consumption when used by multiple layers."

I'm pretty sure that the issue i've described is already fixed in Unity version over 4.5.5.

Comment

People who like this

0 Show 3 · 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 juan-jo · Aug 26, 2016 at 06:08 PM 0
Share

The problem persists (or is back) in Unity 5.4

The trigger is 'consumed' when used by the first layer.

avatar image dazzle_jukka · Jul 12, 2017 at 05:47 PM 0
Share

Just in case someone stumbles over this thread while searching for an answer. After a while I managed to figure out how to get trigger parameters to work on multiple layers in Unity 2017.1. So yeah, triggers do work on multiple layers but the gotcha is this:

Let's say that we have Base layer, layer A and layer B and a trigger parameter MrX. All of them have a transition that will be triggered by MrX and on the Base and A layer the transition doesn't have exit time but on layer B the transition has an exit time. In this scenario, the transition would be successfully performed on the layers Base and A, but not on B, because when the statemachine on layer B evaluates transition conditions, it will have missed the trigger due to exit time.

Hopefully this clears up. And this is just something that seemed to be the case when I was playing around and testing it, so don't treat this as the absolute truth :D

avatar image datagreed dazzle_jukka · Jul 25, 2020 at 07:43 PM 0
Share

None of my transitions have an exit time and sometimes the trigger is "consumed" by one layer, sometimes by another, I did not find any pattern for this, unfortunately.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animator component prevents NavMeshAgent from disabling/enabling dynamically 0 Answers

Animator does not make transition if speed = 0 3 Answers

Animation Impulse System? 1 Answer

Get the clip length (accounting for speed multipliers) of any animation state at runtime 1 Answer

Animation Mecanim - Parts of model displaces after animating 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