예제 #1
0
    bool FocusButtonPressed()
    {
        //if (NInput.GetKey(KeyCode.Backslash))
        //lastInput = "\\";

        return(NInput.GetKeyDown(KeyCode.T) || NInput.GetKey(KeyCode.Backslash));
    }
예제 #2
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        float iH = NInput.GetAxis("Horizontal");
        float iV = NInput.GetAxis("Vertical");

        speedMult = NInput.GetKey(KeyCode.LeftShift) ? runSpeedMult : walkSpeedMult;

        Vector3 iVec = new Vector3(iH, 0, iV);

        Vector3 move = iVec.normalized * speedSlope.Evaluate(iVec.magnitude) * speedMult;// * Time.deltaTime;

        move = transform.forward * move.z + transform.right * move.x;

        // vertical speed
        if (controller.isGrounded)
        {
            vSpeed = 0;

            if (NInput.GetKeyDown(KeyCode.Space))
            {
                vSpeed = 8;
            }
        }

        vSpeed -= gravity * Time.deltaTime;
        vSpeed  = Mathf.Clamp(vSpeed, -54, 54);
        move.y  = vSpeed;
        //float x = speedSlope.Evaluate(Mathf.Abs(f)) * Time.deltaTime;
        //float y = speedSlope.Evaluate(Input.GetAxis("Vertical")) * Time.deltaTime;

        controller.Move(move * Time.deltaTime);

        // MOUSELOOK
        float rotX = NInput.GetAxis("Mouse X") * mouseSensitivity;
        float rotY = NInput.GetAxis("Mouse Y") * mouseSensitivity;

        totalX += rotX;
        totalY += rotY;

        totalY = Mathf.Clamp(totalY, -85, 85);

        Quaternion yQuaternion = Quaternion.AngleAxis(totalY, Vector3.left);
        Quaternion xQuaternion = Quaternion.AngleAxis(totalX, Vector3.up);

        head.localRotation      = yQuaternion;
        transform.localRotation = xQuaternion;

        if (NInput.GetKeyDown(KeyCode.B))
        {
            CmdBoxSpawn();
        }
    }