Example #1
0
    // Update is called once per frame
    void Update()
    {
        // using controller input to move player
        characterMover.inputY = Input.GetAxis("Vertical") / 4;
        characterMover.inputX = Input.GetAxis("Horizontal") / 4;

        if (Input.GetAxis("Vertical") == 0 && Input.GetAxis("Horizontal") == 0)
        {
            isMoving = false;
        }
        else
        {
            isMoving = true;
        }
        // work out if we are attacking this will work but not like this
        // TODO: change to use a state machine
        if (Input.GetAxis("Action") > 0)
        {
            isAttacking = true;
            worldInteracter.TryHit(charDirection.getVectorDirection());
        }
        else
        {
            isAttacking = false;
        }

        // set direction and animation states
        charDirection.SetDirection(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        characterAnimator.UpdateAnimationState(isMoving, isAttacking, (float)charDirection.currentCharacterDirection);
    }