예제 #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float mouseX, mouseY;
        float speed = this.speed;

        float runAxis      = Input.GetAxis("Fire1");
        float angularSpeed = 60.0f;

        if (Input.GetKey(KeyCode.LeftShift) || runAxis != 0)
        {
            speed *= 5.0f;
        }

        if (Input.GetKey(KeyCode.W))
        {
            Walk(speed);
        }

        if (Input.GetKey(KeyCode.S))
        {
            Walk(-speed);
        }

        if (Input.GetKey(KeyCode.A))
        {
            Strafe(-speed);
        }

        if (Input.GetKey(KeyCode.D))
        {
            Strafe(speed);
        }

        /*
         * if (Input.GetKey(KeyCode.Q))
         * {
         *  Roll(-Time.deltaTime * angularSpeed);
         * }
         * if (Input.GetKey(KeyCode.E))
         * {
         *  Roll(Time.deltaTime * angularSpeed);
         * }
         */
        if (Input.GetKey(KeyCode.R))
        {
            Fly(speed);
        }
        if (Input.GetKey(KeyCode.F))
        {
            Fly(-speed);
        }

        //BoidManager.PrintVector("OVR Forward: ", ovrCamera.transform.forward);

        mouseX = Input.GetAxis("Mouse X");
        mouseY = Input.GetAxis("Mouse Y");


        Yaw(mouseX * Time.deltaTime * angularSpeed);

        transform.rotation = Quaternion.Slerp(transform.rotation, desiredRotation, Time.deltaTime);

        float contYaw   = Input.GetAxis("Yaw Axis");
        float contPitch = Input.GetAxis("Pitch Axis");

        CreatureManager.PrintFloat("Yaw Axis: ", contYaw);
        CreatureManager.PrintFloat("Pitch Axis: ", contPitch);
        if (Mathf.Abs(contYaw) > 0.2f)
        {
            //Yaw(contYaw * Time.deltaTime * angularSpeed);
        }
        // If in Rift mode, dont pitch
        //if (ovrCamera == null)w
        //{
        //Pitch(-mouseY * Time.deltaTime * angularSpeed);
        //Pitch(contPitch * Time.deltaTime * angularSpeed);
        //}
        //else
        {
            //Fly(-contPitch * speed);
        }

        float contWalk   = Input.GetAxis("Vertical");
        float contStrafe = Input.GetAxis("Horizontal");

        if (Mathf.Abs(contWalk) > 0.1f)
        {
            //Walk(contWalk * speed);
        }
        if (Mathf.Abs(contStrafe) > 0.1f)
        {
            //Strafe(contStrafe * speed);
        }
    }