private void LateUpdate() { #region Camera rotX = Input.GetAxis("Mouse X") * GameManager.Instance.lookSensitivity * Time.deltaTime; rotY -= Input.GetAxis("Mouse Y") * GameManager.Instance.lookSensitivity * Time.deltaTime; rotY = Mathf.Clamp(rotY, -80f, 80f); if (target) { Transform currentHead = headJoint.transform; currentHead.LookAt(target); cam.transform.LookAt(target); //cam.transform.localRotation = Quaternion.Lerp(cam.transform.localRotation, currentHead.transform.rotation, 0.001f); cam.transform.localRotation = Quaternion.Euler(new Vector3(cam.transform.localRotation.eulerAngles.x, 0, 0)); headJoint.transform.rotation = Quaternion.Lerp(headJoint.transform.rotation, currentHead.transform.rotation, 0.001f); headJoint.transform.rotation = Quaternion.Euler(new Vector3(0, headJoint.transform.rotation.eulerAngles.y, 0)); } else { cam.transform.localRotation = Quaternion.Lerp(cam.transform.localRotation, Quaternion.Euler(rotY, 0, 0), 0.5f); headJoint.transform.Rotate(0, rotX, 0); } flashlight.transform.rotation = Quaternion.Lerp(flashlight.transform.rotation, cam.transform.rotation, 0.1f); #endregion Monster_TV monster = FindObjectOfType <Monster_TV>(); if (monster) { if (monster.alive && monster.blackout.IsOnBlack() && Vector3.Distance(transform.position, monster.transform.position) < 2) { m_isAlive = false; gameOverCanvas.alpha = 1; } } if (!m_isAlive) { if (Input.GetKeyDown(KeyCode.Return)) { SceneManager.LoadScene(0); } } interactButton = false; }
private void Update() { if (PauseManager.isPaused) { return; } #region Raycasting for Interaction // Raycasting for interaction m_uiGame.SetInteractText(""); RaycastHit[] allHits; int layerMask = 1 << gameObject.layer; layerMask = LayerMask.NameToLayer("Interactable"); layerMask = ~layerMask; allHits = Physics.RaycastAll(Camera.main.transform.position, Camera.main.transform.forward, interactReach, layerMask, QueryTriggerInteraction.Collide); foreach (var hit in allHits) { if (hit.transform.gameObject.layer != layerMask) { var interacted = hit.transform.gameObject.GetComponent(typeof(Interactive)) as Interactive; if (interacted != null) { interacted.LookAt(); if (Input.GetKeyDown("e")) { interacted.Interact(); if (interacted.verb == Interactive.Verbs.GET) { items.Add(interacted.GetItem()); } } } } } #endregion target = null; Monster_TV monster = FindObjectOfType <Monster_TV>(); if (monster) { if (monster.alive) { target = monster.screenTransform; } } //Collider[] overlap = Physics.OverlapSphere(transform.position, 5f); //foreach (Collider c in overlap) //{ // if (c.gameObject.GetComponent<Monster_TV>()) // { // c.gameObject.GetComponent<Monster_TV>().alive = true; // target = c.GetComponent<Monster_TV>().screenTransform; // } //} hasFlashlight = false; // Inventory check foreach (Interactive.Items i in items) { if (i == Interactive.Items.FLASHLIGHT) { hasFlashlight = true; } } if (hasFlashlight) { if (Input.GetKeyDown("f")) { // Toggle the flashlight flashlightIsOn = !flashlightIsOn; if (flashlightIsOn) { AudioManager.PlaySound(flashlightSoundOn); } else { AudioManager.PlaySound(flashlightSoundOff); } } flashlight.enabled = flashlightIsOn; } else { flashlight.enabled = false; } }