// Update is called once per frame void Update() { if (Input.GetButton("Fire2")) { line.enabled = true; } else { line.enabled = false; } if (line.enabled) { Ray ray; ray = (Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f))); // ray to center of screen ray.origin = transform.position; LazerManager.updateRay(line, ray, range, maxBounce, 0); } }
// LateUpdate is called once per frame after all update call void LateUpdate() { if (active) { Ray ray; ray = new Ray(transform.position, transform.forward); LazerManager.updateRay(line, ray, range, maxBounce, 0); line.enabled = true; if (temp) { temp = false; active = false; } } else { line.enabled = false; } }