Home>

I am making a 3D game with Unity.

Currently, there is a state like this image.
"Gold Unko Idle" is the state of the character's stationary animation.
"Gold Unko Run" is the animated state of the character running.

The transition between these states is performed by controlling the parameters with the following code.

                  if (MoveDiff == Vector3.zero)
                    {
                        Anim.SetTrigger ("GoldUnkoIdle");
                    }
                    if (MoveDiff! = Vector3.zero)
                    {
                        Anim.SetTrigger ("GoldUnkoRun");
                    }


The Transition parameters for the two states only have one parameter each written in this code.
I'm playing the Idle animation when the character is stationary and the Run animation when it's running, but there was a problem when the two animations transitioned to each other.

When transitioning from Idle to Run, it takes about 3 round trips like "Idle->Run->Idle->Run->Idle->Run".
I would like you to make a transition normally at once, such as "Idle → Run", but that is not the case.
This round trip occurs for about 0.5 seconds after the transition begins.
So, if you look at the animation when transitioning from the stopped state to the running state, it will transition after being awkward and jerky without making a smooth transition.
On the contrary, the same phenomenon occurs when transitioning from Run to Idle.

What is the cause of this phenomenon?
I thought, "At the time of transition from Idel to Run, Idel's Trigger parameter is still true, and as a result, the transition condition from Run to Idle is satisfied and an unintended transition occurs." But I don't know how to verify this.
When using a form in which states can transition to each other like this time, is there no choice but to use another parameter such as bool instead of the Trigger parameter?

  • Answer # 1

    I could solve it by stopping using Trigger and using Bool type parameters.
    I'm not sure yet, but the cause of this symptom when using Trigger is this site (https://marudice.hatenablog.jp/entry/2016/08/27/211243)
    Written in
    "As you can see in practice, the Animator's Trigger parameter remains On until the Transition is resolved, so

    Idle->Idle (Idle's Trigger is not used and remains on)->Run->Immediately return to Idle "
    I think it's because something like this is happening.