// Update graphics motions
    public void Update()
    {
        // var mouseInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
        var mouseInput = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

        mouseInput *= _sensitivity;                                             // no Time.deltaTime, because "you do not need to be concerned about varying frame-rates when using this value."

        float smooth = Mathf.Clamp(1.0f - 60.0f * Time.deltaTime, 0.01f, 1.0f); // amount of mouse smoothing to apply

        smoothedMouse = (1.0f - smooth) * mouseInput + smooth * smoothedMouse;

        float Y_look_direction = +1.0f; // normal Y mouse

        // Y_look_direction=-1.0f; // inverted Y look

        // Apply incremental mouse movement to the look directions
        ui.pitch += -Y_look_direction * smoothedMouse.y; // degrees rotation about X axis (pitch)
        ui.yaw   += smoothedMouse.x;                     // degrees rotation about Y axis (yaw)

        currentVehicle.VehicleUpdate(ref ui, playerTransform, cameraTransform);

        lastFpsTime += Time.deltaTime;
        lastFpsCount++;
        if (lastFpsTime > 10.0f)
        {
            float fps = (int)(lastFpsCount / lastFpsTime);
            Debug.Log("Framerate: " + fps + " frames per second");
            lastFpsCount = 0;
            lastFpsTime  = 0;
        }
    }
Ejemplo n.º 2
0
    private Vector2 smoothedMouse; // for smoothing between frames

    // Update graphics motions
    public void Update()
    {
        // var mouseInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
        var mouseInput = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

        mouseInput *= _sensitivity; // no Time.deltaTime, because "you do not need to be concerned about varying frame-rates when using this value."

        float smooth = 0.5f;        // amount of mouse smoothing to apply

        smoothedMouse = (1.0f - smooth) * mouseInput + smooth * smoothedMouse;

        float Y_look_direction = +1.0f; // normal Y mouse

        // Y_look_direction=-1.0f; // inverted Y look

        // Apply incremental mouse movement to the look directions
        ui.pitch += -Y_look_direction * smoothedMouse.y; // degrees rotation about X axis (pitch)
        ui.yaw   += smoothedMouse.x;                     // degrees rotation about Y axis (yaw)

        currentVehicle.VehicleUpdate(ref ui, playerTransform, cameraTransform);
    }