Пример #1
0
    // Update is called once per frame
    void Update()
    {
        mousePos.x += Input_scr.GetCameraXMovement() * sensitivity;
        mousePos.y += Input_scr.GetCameraYMovement() * sensitivity;

        mousePos.x = Mathf.Clamp(mousePos.x, -32, 31);
        mousePos.y = Mathf.Clamp(mousePos.y, -31, 32);

        transform.localPosition = mousePos;
    }
Пример #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
        {
            godMode = !godMode;
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            SceneManager.LoadScene("Level" + (PowerUp_scr.level + 1).ToString());
            PowerUp_scr.level += 1;
        }
        if (Input_scr.OnUIBackwardPressed())
        {
            Application.LoadLevel("Menu");
        }
        // Weapon
        if (Input_scr.OnKnifePressed() && knife.activeSelf == false)
        {
            StartCoroutine(Knife());
        }

        // Rotation
        targetRotY += Input_scr.GetCameraXMovement() * mouseSensitivity * Time.deltaTime;

        rotY = Mathf.LerpAngle(rotY, targetRotY, lerpSpeed);

        Quaternion localRotation = Quaternion.Euler(0, rotY, 0.0f);

        transform.localRotation = localRotation;

        // Movement
        cc.SimpleMove(transform.forward * Input_scr.GetPlayerMovement().y * 12);
        cc.SimpleMove(transform.right * Input_scr.GetPlayerMovement().x * 12);

        // Gravity
        cc.SimpleMove(Vector3.down);

        // Sound
        if (Vector3.Distance(transform.position, prevPos) > 0.5f)
        {
            if (stepCount < 0)
            {
                stepCount = 18;
                GetComponent <AudioSource>().Play();
            }
            prevPos = transform.position;
        }
        stepCount--;
    }