Swipe Issues with GearVR

Hello, I’m getting all sorts of weird things happen when swiping on the GearVR. I am displaying mouseX/Y on screen and seeing massive variations with what (to me) feels like identical swipe motions (anything from 4.0 to 70.0+). Also, I think I need something in the code to look at which direction has the greatest movement as swiping - even slightly diagonally - produces unexpected results. Is anyone else seeing this? t’s also entirely possible that I am missing something fundamental…

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Player : MonoBehaviour {

    public Text gazeText;
    public Text swipeText;
    public Text tapText;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
        var camera = GetComponent<Camera>();
        var lookDirection = camera.transform.rotation * Vector3.forward;
        gazeText.text = lookDirection.ToString();
        if (Input.GetButtonDown("Tap"))
        {
            tapText.text = "Tap Detected";
        }
        var mouseX = Input.GetAxis("Mouse X");
        if (mouseX > 5.0f)
        {
            swipeText.text = mouseX + " Swipe Detected on X Axis";
        }
        var mouseY = Input.GetAxis("Mouse Y");
        if (mouseY > 5.0f)
        {
            swipeText.text = mouseY + " Swipe Detected on Y Axis";
        }

    }
}
1 Like

I was having the same issues and then I figured out the problem after a few hours of debugging. In the video, Axis information was used to detect swiping which works to an extent on the computer with a real mouse but when applied to the gear VR touch pad, it doesn’t act as you think it would. This is because every time the touchpad is touched, the virtual mouse position that the gear VR uses is reset back to a defualt position messing up the axis infomation.

For example: My mouse position said that it was at (1280, 720) for it’s x-y coordinates. When I slid my finger to the right side of the touch pad my slide would (usually) register correctly using the axis information and the final mouse position would be something like (1000, 720) or something close to that. As soon as I touch the touchpad again though, no matter where on the touchpad, the mouse would be reset back to (1280, 720) ready to move around again. Because there was a large jump from (1000, 720) to (1280, 720), the mouse axis would think that I swiped really fast back to the left. This is why things become so unpredictable, especially when sliding diagonally. Another problem with using the axis information is that it relies on how quickly you are sliding your finger over the course of one frame and that can be very unbalanced and unpredictable as well giving you unreliable results.

The best solution is to record the mouse’s x-ycoordinates when the touch pad is pushed down using Input.GetButtonDown(“Tap”), Input.mousePosition.x, and Input.mousePosition.y. Then when the user lets go of the touchpad record the mouse’s x-y coordinates again and subtract them from the starting mouse coordinates. Once you have this information you can then determine if the user slide their finger right, left, up, or down. I also played around on the oculus home menu in the gear VR and this seems to be the way they implemented it as well.

Hope this helps!

Thanks for this detailed explanation Alex. That makes sense. I’ll give that a try later.

1 Like

Privacy & Terms