0
\$\begingroup\$

So the new input system is out, and we're using it for our game. The next hurdle I'm trying to get over is implementing a melee combo ( E->-E->E). Not 100% sure how to get the new system to execute something like that. Right now my trigger isn't resetting. Images of the animator graph at the bottom

public class PlayerController : MonoBehaviour
{
    Rigidbody2D _rigidbody;
    SpriteRenderer _renderer;
    Animator _animator;
    public float fallMultiplier = 2.5f;
    public float lowJumpMultiplier = 2f;

    PlayerInputActions inputActions;
    Vector2 movementInput;
    public bool inInteractionZone;
    public int attackCount = 0;
    public float attackTimeout = 0.5f;

    bool touchingWall;
    private void Awake()
    {
        HRHEventHub.OnPlayerDeath += HRHEventHub_OnPlayerDeath;
        inputActions = new PlayerInputActions();
        inputActions.Player.Move.performed += ctx => movementInput = ctx.ReadValue<Vector2>();
        inputActions.Player.Interact.performed += InteractPressed;
    }

    private void InteractPressed(InputAction.CallbackContext obj)
    {
        //TODO add attack timeout
        //Check if we are inside a interaction zone
        if (inInteractionZone)
        {
            //TODO implement
            return;
        }
        if (attackCount == 0 && _grounded)
        {

            attackCount++;
            _animator.SetTrigger("Attack");
            //_animator.SetBool("ATK1", true);
        }
        else
        if (attackCount == 1 && _grounded)
        {
            attackCount++;
            _animator.ResetTrigger("Attack");
            _animator.SetTrigger("Attack");

        }
        else
        if (attackCount == 2 && _grounded)
        {
            attackCount = 0;
            _animator.ResetTrigger("Attack");
            _animator.SetTrigger("Attack");

        }


    }

}

Animator transition State

\$\endgroup\$
9
  • 1
    \$\begingroup\$ This site tends to give better answers, faster, if you show what you've tried so far and narrow down where you're stuck. How have you tried reading your button inputs so far with the new input system? How have you tried storing them in a history buffer? How have you tried comparing that history buffer against your list of combo patterns? Edit your question to include those details and you should get much better response. :) \$\endgroup\$
    – DMGregory
    May 12 '20 at 14:50
  • \$\begingroup\$ I read ya, added my code \$\endgroup\$
    – Kaitou3d
    May 12 '20 at 17:06
  • \$\begingroup\$ You generally shouldn't need to call ResetTrigger in a situation like this. Can you clarify what you're trying to accomplish, what outcomes you're observing, and what you expect to observe instead? \$\endgroup\$
    – DMGregory
    May 12 '20 at 17:10
  • \$\begingroup\$ What im looking to do is to get the play to press the same key and move from atk1 to atk 2 and so on if the animation is still playing. Right now I can spam the first atk animation, but not get to the remaining animation states \$\endgroup\$
    – Kaitou3d
    May 12 '20 at 17:15
  • \$\begingroup\$ This sounds like a problem in how your animation controller graph is set up. Can you show us how you've configured your animations and the transitions between them? \$\endgroup\$
    – DMGregory
    May 12 '20 at 17:18
1
\$\begingroup\$

I see you have a transition arrow from the "Any" state into "Attack 1"

That means that when you set the "Attack" trigger in the "Attack 1" animation, it's valid for the animator to consume that trigger to transition from "Attack 1" (which is a member of "Any" state) into "Attack 1" again.

Remove that transition arrow so that the animator is forced to use the "Attack 1" to "Attack 2" transition instead.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.