void Update() { if (!firstposition.HasValue) { firstposition = mop.GetObjectPosition(ren); } // On thumb stick press, reset position, velocity, accel if (OVRInput.Get(OVRInput.RawButton.LThumbstick) || OVRInput.Get(OVRInput.RawButton.RThumbstick)) { mop.SetObjectPosition(ren, firstposition.Value); kin.makeStationary(); } }
// Update is called once per frame void Update() { Vector3 gloveCurrentPosition = mop.GetObjectPosition(rglove); float trigger; if (ht.controller == OVRInput.Controller.LTouch) { trigger = OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger) + OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger); } else { trigger = OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger) + OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger); } if (!grabbed && (trigger > 0)) { float distance = Vector3.Distance(mop.GetObjectPosition(rball), gloveCurrentPosition); if (distance < grabDistance) { grabbed = true; kball.makeStationary(); kball.kineticsActive = false; } } if (grabbed && (trigger == 0)) { grabbed = false; kball.kineticsActive = true; } if (grabbed) { mop.SetObjectPosition(rball, gloveCurrentPosition); } }