void Awake() { laserPointerImpl = new GvrLaserPointerImpl(); laserPointerImpl.LaserLineRenderer = gameObject.GetComponent <LineRenderer>(); if (reticle != null) { Renderer reticleRenderer = reticle.GetComponent <Renderer>(); reticleRenderer.sortingOrder = reticleSortingOrder; } }
void Update() { laserpointerimpl = (GvrLaserPointerImpl)GvrPointerManager.Pointer; Quaternion ori = GvrController.Orientation; Ray ray = laserpointerimpl.PointerIntersectionRay; RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { if (GvrController.ClickButtonDown) { objectDetected = hit.collider.gameObject; if (objectDetected.tag == "grabable") { objectGrabbed = objectDetected; var joint = AddConfigurableJoint(); joint.connectedBody = objectGrabbed.GetComponent <Rigidbody> (); objectPicked = true; objectThrown = false; } } } if (objectPicked) { if (GvrController.ClickButton) { objectGrabbed.transform.parent = gameObject.transform; objectGrabbed.transform.localPosition = GvrController.ArmModel.pointerPosition; objectGrabbed.transform.localRotation = ori; controller.SetActive(false); laser.SetActive(false); } } throwVelocity = (GvrController.ArmModel.wristPosition - objLastPosition) / Time.deltaTime; objLastPosition = GvrController.ArmModel.wristPosition; if (objectPicked) { if (GvrController.ClickButtonUp) { ThrowObject(); } } if (objectThrown) { controller.SetActive(true); laser.SetActive(true); } }