Hi Guys,
I have been unable to get the Galaxy VR to detect a swipe. I can successfully get it to detect a tap, but not a swipe.
I’ve tried this code, but I suspect it only supports a swipe on a phones screen and not the Gear VR built in touch pad.
if(Input.touches.Length > 0)
{
var t : Touch = Input.GetTouch(0);
if(t.phase == TouchPhase.Began)
{
//save began touch 2d point
firstPressPos = new Vector2(t.position.x,t.position.y);
}
if(t.phase == TouchPhase.Ended)
{
//save ended touch 2d point
secondPressPos = new Vector2(t.position.x,t.position.y);
//create vector from the two points
currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
//normalize the 2d vector
currentSwipe.Normalize();
//swipe upwards
if(currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
{
Debug.Log("up swipe");
}
//swipe down
if(currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
{
Debug.Log("down swipe");
}
//swipe left
if(currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
{
Debug.Log("left swipe");
}
//swipe right
if(currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
{
LaunchNewAsteroid();
//Debug.Log("right swipe");
}
}
}
Has anyone successfully done this or can provide a link to how to do it ?
Cheers