コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        //gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;

        /*float inptZ = Input.GetAxis("Horizontal");
         * if (inptZ != 0) {
         *      if (inptZ > 0) inptZ = 1;
         *      else inptZ = -1;
         * }*/
        float inptZ = 0;

        if (Input.GetKey(KeyCode.A))
        {
            inptZ = -1;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            inptZ = 1;
        }
        float inptY = Input.GetAxis("Vertical");

        _animator.SetFloat("inputZ", inptZ);
        CheckMousePos();
        if (inptZ != 0)
        {
            Move(inptZ);
        }
        if (inptY != 0 && !_phyo.InAir)
        {
            //_phyo.InAir = true;
            _animator.SetBool("inAir", _phyo.InAir);
            _animator.Play("Armed-Jump");
            //dir2Cursor*jumpspeed
            //_phyo.AddAirForce(Dir2Cursor() * _jumpSpeed);
            _phyo.AddAirForce(new Vector3(inptZ * 2, _jumpSpeed, 0));
        }


        if (Input.GetAxis("Jump") != 0)
        {
            //_animator.Play("Armed-Jump");
            //Roll(inptZ);
        }
        CheckBlock();
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Roll(inptZ);
        }
        CheckAttack();
        if (_rolling)
        {
            _phyo.AddVelocity(new Vector3(inptZ * 30, 0, 0));
        }
    }