// Update is called once per frame void Update() { if (mainCamera == null) { Debug.LogError("RayCaster script was unable to get a camera from Camera.main"); return; } Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 500) == true) { // update crosshair Vector3 newPos = new Vector3(hitInfo.point.x, hitInfo.point.y, hitInfo.transform.position.z); output.text = hitInfo.transform.gameObject.name + "- " + newPos.x + " ," + newPos.y; // check for hits if (Input.GetAxis("Fire1") > 0.0f) { // hit box if (hitInfo.transform.gameObject.tag == "ExplodingBox") { particleController.PlayExplosion(hitInfo.transform.position); // destroy box, could just disable/hide box instead for reuse later Destroy(hitInfo.transform.gameObject); } // hit balloon if (hitInfo.transform.gameObject.tag == "Balloon") { particleController.PlayBalloonPop(hitInfo.transform.position); particleController.PlayWaterDrop(hitInfo.transform.position); // enable cloth on balloon so it droops hitInfo.transform.gameObject.GetComponent <Cloth>().enabled = true; } } } }