Esempio n. 1
0
    void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        float horizontalRotation = FakeControls.GetMouseX();

        transform.Rotate(0.0f, horizontalRotation * rotationSpeed, 0.0f);

        verticalRotation -= FakeControls.GetMouseY();
        verticalRotation  = Mathf.Clamp(verticalRotation, -verticalRotationLimit, verticalRotationLimit);
        Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation * rotationSpeed, 0.0f, 0.0f);

        Vector3 movement = new Vector3(FakeControls.GetHorizontal(), 0.0f, FakeControls.GetVertical());

        controller.Move(new Vector3(0.0f, -gravity * Time.deltaTime, 0.0f));
        controller.Move(transform.TransformDirection(movement) * Time.deltaTime * speed);
    }