Example #1
0
    //[Header("***** Ouput signals *****")]
    //public float Dup;
    //public float Dright;
    //public float Dmag;
    //public Vector3 Dvec;
    //public float Jup;//
    //public float Jright;//

    //public bool run;
    //public bool jump;
    //public bool lastJump;
    //public bool attack;
    //public bool lastAttack;

    //[Header("***** Others *****")]

    //public bool inputEnabled = true;

    //private float targetDup;
    //private float targetDright;
    //private float velocityDup;
    //private float velocityDright;

    // Start is called before the first frame update
    //void Start()
    //{

    //}

    // Update is called once per frame
    void Update()
    {
        kkeyA.Tick(Input.GetKey(keyA));
        kkeyB.Tick(Input.GetKey(keyB));
        kkeyLB.Tick(Input.GetKey(keyLB));
        kkeyLT.Tick(Input.GetKey(keyLT));
        kkeyRB.Tick(Input.GetKey(keyRB));
        kkeyRT.Tick(Input.GetKey(keyRT));
        kkeyJstick.Tick(Input.GetKey(keyJstick));
        //print(kkeyJstick.OnPressed);
        //print(kkeyB.IsExtending && kkeyB.IsPressing);

        if (mouseEnable == true)
        {
            Jup    = Input.GetAxis("Mouse Y") * 3.0f * mouseSensitivityY;
            Jright = Input.GetAxis("Mouse X") * 2.5f * mouseSensitivityX;
        }
        else
        {
            Jup    = (Input.GetKey(keyJUp) ? 1.0f : 0) - (Input.GetKey(keyJDown) ? 1.0f : 0);
            Jright = (Input.GetKey(keyJRight) ? 1.0f : 0) - (Input.GetKey(keyJLeft) ? 1.0f : 0);
        }


        targetDup    = (Input.GetKey(keyUp) ? 1.0f : 0) - (Input.GetKey(keyDown) ? 1.0f : 0);
        targetDright = (Input.GetKey(keyRight) ? 1.0f : 0) - (Input.GetKey(keyLeft) ? 1.0f : 0);

        if (inputEnabled == false)
        {
            targetDup    = 0;
            targetDright = 0;
        }
        Dup    = Mathf.SmoothDamp(Dup, targetDup, ref velocityDup, 0.1f);
        Dright = Mathf.SmoothDamp(Dright, targetDright, ref velocityDright, 0.1f);

        Vector2 tempOAxis = SquareToCircle(new Vector2(Dright, Dup));
        float   Dright2   = tempOAxis.x;
        float   Dup2      = tempOAxis.y;


        Dmag = Mathf.Sqrt(Dup2 * Dup2 + Dright2 * Dright2);
        Dvec = Dright2 * transform.right + Dup2 * transform.forward;

        run     = (kkeyA.IsPressing && !kkeyA.IsDelaying) || kkeyA.IsExtending;
        defense = kkeyLB.IsPressing;
        jump    = kkeyB.OnPressed;
        //attack = kkeyC.OnPressed;
        rb     = kkeyRB.OnPressed;
        rt     = kkeyRT.OnPressed;
        lb     = kkeyLB.OnPressed;
        lt     = kkeyLT.OnPressed;
        lockon = kkeyJstick.OnPressed;
    }
Example #2
0
    //[Header("***** Ouput signals *****")]
    //public float Dup;
    //public float Dright;
    //public float Dmag;
    //public Vector3 Dvec;
    //public float Jup;//
    //public float Jright;//

    //public bool run;
    //public bool jump;
    //protected bool lastJump;
    //public bool attack;
    //protected bool lastAttack;

    //[Header("***** Others *****")]

    //public bool inputEnabled = true;

    //protected float targetDup;
    //protected float targetDright;
    //protected float velocityDup;
    //protected float velocityDright;

    //void start()
    //{

    //}

    // Update is called once per frame

    void Update()
    {
        buttonA.Tick(Input.GetButton(btnA));
        buttonB.Tick(Input.GetButton(btnB));
        buttonC.Tick(Input.GetButton(btnC));
        buttonD.Tick(Input.GetButton(btnD));
        buttonLB.Tick(Input.GetButton(btnLB));
        buttonLT.Tick(Input.GetButton(btnLT));
        buttonRB.Tick(Input.GetButton(btnRB));
        buttonRT.Tick(Input.GetButton(btnRT));
        buttonJstick.Tick(Input.GetButton(btnJstick));

        Jup    = -1 * Input.GetAxis(axisJup);
        Jright = Input.GetAxis(axisJright);

        targetDup    = Input.GetAxis(axisY);
        targetDright = Input.GetAxis(axisX);

        if (inputEnabled == false)
        {
            targetDup    = 0;
            targetDright = 0;
        }
        Dup    = Mathf.SmoothDamp(Dup, targetDup, ref velocityDup, 0.1f);
        Dright = Mathf.SmoothDamp(Dright, targetDright, ref velocityDright, 0.1f);

        Vector2 tempOAxis = SquareToCircle(new Vector2(Dright, Dup));
        float   Dright2   = tempOAxis.x;
        float   Dup2      = tempOAxis.y;

        Dmag = Mathf.Sqrt(Dup2 * Dup2 + Dright2 * Dright2);
        Dvec = Dright2 * transform.right + Dup2 * transform.forward;

        run  = (buttonA.IsPressing && !buttonA.IsDelaying) || buttonA.IsExtending;
        jump = buttonA.OnPressed && buttonA.IsExtending;


        defense = buttonLB.IsPressing;
        //attack = buttonC.OnPressed;
        rb     = buttonRB.OnPressed;
        rt     = buttonRT.OnPressed;
        lb     = buttonLB.OnPressed;
        lt     = buttonLB.OnPressed;
        lockon = buttonJstick.OnPressed;
    }