Hi Everyone I am developing an Immersive app and having a little trouble figuring out how to support both single an dual Motion Controller inputs( if that is even possible) . I will include my code below but currently I am polling the Interaction source state of both controllers and and applying my interaction logic after they meet the input thresholds.
What I'm trying to do is get the number of current Interaction source states using var interactionSourceState = InteractionManager.GetCurrentReading ();
and based on the length of the returned array . Determine if one or two controllers are being detected and then handle the input based on the respective indexes for one of both controllers. Is my thinking incorrect? Am I missing something about how the Interaction Source States are working ?
Here is my code for reference of how I am implementing this :
var interactionSourceState = InteractionManager.GetCurrentReading ();
//*** If Single controller if (interactionSourceState.Length == 1) { //*** Controller Stick 1 if (interactionSourceState [0].thumbstickPosition.x >= 0.1f) { Debug.Log (" Left Stick moved Left"); } if (interactionSourceState [0].thumbstickPosition.x <= -0.1f) { Debug.Log (" Left Stick moved Right"); } //*** Touchpad 1 if (interactionSourceState [0].touchpadPosition.x >= 0.1f) { Debug.Log (" Left Stick moved Left"); } if (interactionSourceState [0].touchpadPosition.x <= -0.1f) { Debug.Log (" Left Stick moved Right"); Vector3 rotation = Vector3.up * 3.0f * Time.deltaTime * sensitivity; this.transform.Rotate (rotation); } //*** If two controllers } else if (interactionSourceState.Length > 1) { //*** Controller Stick 1 if (interactionSourceState [0].thumbstickPosition.x >= 0.1f) { Debug.Log (" Left Stick moved Left"); } if (interactionSourceState [0].thumbstickPosition.x <= -0.1f) { Debug.Log (" Left Stick moved Right"); } //*** Touchpad 1 if (interactionSourceState [0].touchpadPosition.x >= 0.1f) { Debug.Log (" Left Stick moved Left"); } if (interactionSourceState [0].touchpadPosition.x <= -0.1f) { Debug.Log (" Left Stick moved Right"); } //*** Control Stick 2 if (interactionSourceState [1].thumbstickPosition.x >= 0.1f) { Debug.Log (" Right Stick moved Left"); } if (interactionSourceState [1].thumbstickPosition.x <= -0.1f) { Debug.Log (" Right Stick moved Right"); } //*** Touchpad 2 if (interactionSourceState [1].touchpadPosition.x >= 0.1f) { Debug.Log (" Left Stick moved Left"); } if (interactionSourceState [1].touchpadPosition.x <= -0.1f) { Debug.Log (" Left Stick moved Right"); } }
Thank you very much , any and all input is appreciated I feel like I might be missing something in my implementation .