Blend between idle animations using a separate transition animation

I have an enemy object which has two idles - “NormalMode” for when not engaging the player, and “AttackMode” as a battle stance - so the following animations in total:

  • NormalMode (loops)
  • SwitchToAttackMode
  • AttackMode (loops)
  • SwitchToNormalMode
  • Attack (which should blend from any state)

I haven’t used mechanim much in the past so I am trying to figure out how to incorporate this flow in a good way, but so far I haven’t found any specific documentation on this particular case. Basically, in my script I need to be able to say “Now you should be in attack mode”, which blends from NormalMode to the AttackMode using SwitchToAttackMode inbetween - and vice versa.

So far documentation I’ve seen on animation states only describes how to blend between two states with no specific inbetween animation - but I essentially want the following:

  1. Blend for ~0.2s from “idle” to “SwitchToAttackMode”
  2. Play “SwitchToAttackMode” in its entirety
  3. Blend for ~0.2s at the end of “SwitchToAttackMode” to “AttackMode”

The by far most optimal solution would be to have something like an boolean “isInAttackStance” set up in mechanim that a script can just change, and it seamlessly does the above whenever needed. This is my current mechanim setup:

But the above feels a bit wrong, since “SwitchToAttackMode” isn’t a goal state in itself, it’s just an intermediate step. I suspect I also need a boolean that triggers things properly, but I can’t figure out quite how to put it all together.

Could anyone point me in the right direction here? It feels like there should be an easy, obvious way to do this almost entirely within mechanim, but I’m not quite seeing it.

Solved with the help of @ignacevau - changed to use bool rather than a trigger, but the basic concept works the same. Seems reliable - thanks for the help!