how can one-time transition and re-transition to state in mecanim ?

hello~

I need to play hit-animation any time when hit. therefore I added a bool-hit variable and set it to transition condition to ‘hit-state’.
and ‘hit-state’ back to idle-state at end of animation, but it re-transition to ‘hit-state’ because of ‘bool-hit’ is still true.

of course i know this example

animator.SetBool( ‘bool-hit’, true);

if( animator is in ‘hit-state’ ? )
animator.SetBool( ‘bool-hit’, false);

but above example is very annoyed. and it is not useful reenter hit-state during hit-state cause of double hit before end of hit animation.
In UnrealEngine4, I can handle it by AnimMontage ( it allow user to play any animation in animation graph node tree )

is there any useful solution for it?

mecanim 4.3 release note

  • Added Animator.GotoState scripting function. This function allow you at runtime to transition to any state in your controller.
  • Trigger parameter, a trigger is a boolean parameter that is reset by the controller when consumed by a transition.

I will test it. I love you Unity4.3 ( not 4.2, just 4.3 )

1 Like