private void OnTriggerEnter(Collider collider) { if (collider.gameObject.GetComponent <VRGameController>() != null) { VRGameController gameControllerObject = collider.gameObject.GetComponent <VRGameController>(); controllerReference = gameControllerObject.Controller; collisionForce = controllerReference.velocity.magnitude * impactMagnifier; ushort hapticStrength = Convert.ToUInt16(collisionForce / maxCollisionForce); gameControllerObject.Vibrate(hapticStrength); float collisionMidi = ModelUtility.Remap(collisionForce, 0, 100, 70, 127); List <float> pianoData = new List <float>(); pianoData.Add(midiNote); pianoData.Add(collisionMidi); OSCHandler.Instance.SendMessageToClient("myClient", "/pianoKey/" + keyNumber, pianoData); textComponent.text = "/pianoKey/" + keyNumber + ", " + midiNote + " , " + collisionMidi; } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag != "Pad") { VRGameController gameControllerObject = collision.gameObject.GetComponent <VRGameController>(); SteamVR_Controller.Device controllerReference = gameControllerObject.Controller; ushort hapticStrength = Convert.ToUInt16(collisionForce / maxCollisionForce); gameControllerObject.Vibrate(hapticStrength); collisionForce = controllerReference.velocity.magnitude * impactMagnifier; float collisionMidi = ModelUtility.Remap(collisionForce, 0, 100, 70, 127); List <float> padData = new List <float>(); padData.Add(padY); padData.Add(padX); padData.Add(midiNote); padData.Add(collisionMidi); OSCHandler.Instance.SendMessageToClient("myClient", "/drumPad", padData); textComponent.text = "/drumPad: " + padData[0] + ", " + padData[1] + ", " + midiNote + " , " + collisionMidi; } StartCoroutine(Reposition()); }