Search code examples
unity-game-engineanimator

Unity Animator Transition goes to another state that i not expect


My animator state machine

<table border="1">
<tr>
<th>State Change</th>
<th>Conditions</th>
<th>Input Control</th>
</tr>
<tr>
<td>Idle -> Walk</td>
<td>IsMove == true</td>
<td>MouseDown anywhere in game</td>
</tr>
<tr>
<td>Walk -> Idle</td>
<td>IsMove == false</td>
<td>MouseUp anywhere in game</td>
</tr>
<tr>
<td>Walk -> Attack</td>
<td>Trigger "Attack"</td>
<td>MouseUp on enermies</td>
</tr>
<tr>
<td>Attack -> Idle</td>
<td>None</td>
<td>None</td>
</tr>
</table>

    When MouseUp on enermies, it occurs two things:
    Trigger "Attack" and set "IsMove" to false.
    I'm sure that trigger "Attack" happens before set "IsMove" to false.
    But state goes to Walk -> Idle, not Walk -> Attack.
    Can anyone tell me why? thank you!


Solution

  • I know the answer.
    I not sure why but it seems unity will process all the update of MonoBehaviour than goes to animator.
    So it doesn't matter whether Trigger "Attack" first or set "IsMove" to false first.
    When state machine is going to change, "IsMove" is false already.