Mecanim Animation Parameter Types: Boolean vs. Trigger

Hi everyone. I’m using Unity 4.3.1 and in the animation state machine window, I can add 4 types of parameters: int, float, Bool and Trigger. What is the difference between Bool and Trigger?

They seem to be the same (both have checkbox interface). There’s nothing about the “Trigger” parameter type in Unity Docs. Instead, there’s a vector type that’s no longer in Unity. Unity - Manual: Animation Parameters

Trigger is new added in 4.3. My understanding is that it is a “one-shot” Boolean, which can be triggered (i.e. set to “true”) for a single frame only, after which it automatically reverts back to false.

Prior to this, it was somewhat difficult to implement state transitions that you wanted to take immediate effect but then return (i.e. such as firing a gun), because you had to wait for the transition to begin before resetting the Bool with logic such as:

// Set the Bool to transition to the firing state
animator.SetBool("Firing", true);
// Once transition has begun, reset the bool
if (animator.GetNextAnimatorStateInfo(0).IsName("Firing")) {
    animator.SetBool("Firing", false);
}

It works like this:

Let’s say you have an animation that plays when a bool is set to true. After the animation is complete the bool should be set to false again in order to transit to another state.

This used to be achieved by code, but now you can use a Trigger instead. It’s a bool that will be set to false automatically after the completion of animation.

Quite useful, huh?

For kind of info,

In unity’s parameter windows both Trigger and Bools seems same,

But from Transition’s inspector window one can disguise it, for Bools it shows checkbox while for Trigger it won’t…