void Update() { if (eyesClosing) { eyesTimer += Time.deltaTime; if (eyesTimer >= 2) { dreamBed.Dream(); } return; } mouseOver = false; Ray ray = new Ray(transform.position, transform.forward); RaycastHit rayHit = new RaycastHit(); if (Physics.Raycast(ray, out rayHit)) { Debug.DrawLine(rayHit.point, transform.position); Photograph photo = rayHit.collider.gameObject.GetComponent <Photograph>(); Grader grader = rayHit.collider.gameObject.GetComponentInParent <Grader>(); Bed bed = rayHit.collider.gameObject.GetComponent <Bed>(); if (bed == null) { bed = rayHit.collider.gameObject.GetComponentInParent <Bed>(); } if (photo != null) { mouseOver = true; if (Input.GetButtonDown("Fire1")) { if (grabbedPhoto != null) { grabbedPhoto.transform.position = photo.transform.position; grabbedPhoto.transform.rotation = photo.transform.rotation; grabbedPhoto.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; grabbedPhoto.shrink(); photosToGrade.Remove(grabbedPhoto); } grabbedPhoto = photo; grabbedPhoto.transform.position = new Vector3(0, -10, 0); grabSound.pitch = Random.Range(0.75f, 2f); grabSound.Play(); } photosToGrade.Remove(grabbedPhoto); } else if (grader != null) { if (Input.GetButtonDown("Fire1")) { grader.Click(); } grader.talk(); } else if (bed != null && Input.GetButtonDown("Fire1")) { dreamBed = bed; eyesClosing = true; eyes.gameObject.SetActive(true); eyes.GetComponent <Animator>().SetTrigger("close"); //bed.Dream(); } else if (grabbedPhoto != null && Input.GetButtonDown("Fire1")) { grabbedPhoto.transform.position = rayHit.point + rayHit.normal * .05f; grabbedPhoto.transform.rotation = Quaternion.LookRotation(-rayHit.normal, Vector3.up); if (rayHit.normal.y < .5f) { grabbedPhoto.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; grabbedPhoto.grow(); if (rayHit.transform.name == "Grading Wall") { photosToGrade.Add(grabbedPhoto); } } else { grabbedPhoto.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; grabbedPhoto.shrink(); photosToGrade.Remove(grabbedPhoto); } pinSound.pitch = Random.Range(.75f, 2f); pinSound.Play(); grabbedPhoto = null; } } if (photosToGrade.Count == 3) { tutorialText.SetActive(false); } else { tutorialText.SetActive(true); } }