I have a basic animator setup for my Unity Character which has a "block" functionality when pressing the E key. So far, so good.

However I've made a transition from "Blocking Idle" to "Blocking_React" (which means that the character was hit) using a Trigger "tookDamage" (default to false). The problem is that the character gets hit but does not transition to "Blocking_React" animation.

Code Sample:

//From Character Controller script
if (Input.GetKeyDown(KeyCode.E) && !_isBlocking)
            _animator.SetBool("isBlocking", true);
            _isBlocking = true;
        else if (Input.GetKeyUp(KeyCode.E) && _isBlocking)
            _animator.SetBool("isBlocking", false);
            _isBlocking = false;
//From my Character script

public void TakeDamage(float damage)
        health -= damage;

And this is my transition:

animator screenshot

Am I missing something?

  • 1
    \$\begingroup\$ Have you checked that TakeDamage method is called on hit? How you exit from the React state? Is the Idle state the active one upon hit? \$\endgroup\$ – Nikaas Nov 8 '17 at 9:01
  • \$\begingroup\$ The TakeDamage method is called each time the player gets hit, yes! I simply linked the transition back to Blocking Idle with "has Exit Time" checked, nothing special! @Nikaas \$\endgroup\$ – Valamorde Nov 8 '17 at 10:08
  • \$\begingroup\$ The only reason I see for this not to work is that you are not in the Standing_Block_Idle state when SetTrigger is called. \$\endgroup\$ – Uri Popov Nov 8 '17 at 12:26
  • \$\begingroup\$ That's what is weird, while holding down "E" it enters the Standing_Block_idle state successfully, it just doesn't transition to Standing_Block_React_Large... @UriPopov Could it be a bug? \$\endgroup\$ – Valamorde Nov 8 '17 at 13:18
  • \$\begingroup\$ I dont know I tried replicating it and it worked fine for me. You could try changing the blend on the transition maybe that is messing it up. \$\endgroup\$ – Uri Popov Nov 8 '17 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.