void Update() { input.RightTriggerDown(); Transform controller = input.controllerPosition();// Get position of the controller RaycastHit hit; if (Physics.Raycast(controller.position, controller.forward, out hit, 100)) // Cast a ray and saves the hit point and object { this.gameObject.GetComponent <Canvas>().enabled = true; hitpoint = hit.point; transform.position = hitpoint; // Change the position of the reticle to the hit point Vector3.MoveTowards(transform.position, controller.position, 0.05f); // Push the point just a little closer to the controller to make sure it is not hidden by the target // Check if the user shoots if (input.RightTriggerDown()) { GameObject hitObj = hit.transform.gameObject; if (hitObj.tag == "target") { rightHand.GetComponent <AudioSource>().Play(); Destroy(hitObj); score += pointsPerTarget; } } } else { this.gameObject.GetComponent <Canvas>().enabled = false; } }
// Update is called once per frame void Update() { RaycastHit hit; Transform controller = input.controllerPosition(); if (Physics.Raycast(controller.position, controller.forward, out hit, 100)) { hitPoint = hit.point; ShowLaser(hit); // Check if the user selects an item if (input.RightTriggerDown()) { GameObject hitObj = hit.transform.gameObject; if (hitObj.tag == "Level_1") { // Load new scene SceneManager.LoadScene("Level_2"); } else if (hitObj.tag == "Shooting_Tutorial") { // Load new scene SceneManager.LoadScene("Shooting_Tutorial"); } else if (hitObj.tag == "Teleportation_Tutorial") { // Load new scene SceneManager.LoadScene("Teleportation tutorial"); } } } else { laser.SetActive(false); } }