Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Hammo · Feb 20, 2015 at 09:59 AM · swipesamsung

How to detect SWIPE on Gear VR

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bonahona · Apr 13, 2015 at 09:36 PM

The Gear Vr touchpad is mapped up like a mouse in unity. You can use Input.GetAxis("Mouse X") and Input.GetAxis("Mouse Y") to read the motion of the finger on the touchpad. Input.GetMouseButton(0) will detect if the finger touches the touchpad or not.

With this data, it's quite simple to build your own implementation of simple gesture detection.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Jan Rabe · Mar 28, 2016 at 02:58 PM

     void Start()
     {
       OVRTouchpad.Create();
       OVRTouchpad.TouchHandler += HandleTouchHandler;
     }
 
     private void HandleTouchHandler(object sender, EventArgs e)
     {
       var touchArgs = (OVRTouchpad.TouchArgs) e;
       if (touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap)
       {
         Debug.Log("Received SingleTap");
       }
       else
       {
         Debug.Log("Received " + e);
       }
     }
   }

source: http://forum.unity3d.com/threads/samsung-gear-vr-detect-tap-swipe.298346/#post-2270467

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by frikisoni · Oct 18, 2019 at 08:57 AM

I used this and it completely worked for me , as touchpad in GearVR works similar as a mouse.

 Vector3 FP,LP;
 float DragDistance=20f;
 void Update()
 {
 
         if (Input.GetMouseButtonDown(0))                                       //Swipe using Buttonup/ButtonDown
         {
             FP = Input.mousePosition;
         }
         if (Input.GetMouseButtonUp(0))
         {
             LP = Input.mousePosition;
         }
 
         if (Mathf.Abs(LP.x - FP.x) > DragDistance || Mathf.Abs(LP.y - FP.y) > DragDistance) //Swipe happened;
         {
             if (Mathf.Abs(LP.x - FP.x) > Mathf.Abs(LP.y - FP.y))
             {   //If the horizontal movement is greater than the vertical movement...
                 if ((LP.x > FP.x))  //If the movement was to the right)
                 {   //Right swipe
                   
                 }
                 else
                 {   //Left swipe
                    
                 }
             }
             else
             {   //the vertical movement is greater than the horizontal movement
                 if (LP.y > FP.y)  //If the movement was up
                 {   //Up swipe
                     
                 }
                 else
                 {   //Down swipe
                     
                 }
             }
         }
         else
         {
                                         //Tap Functionality
         }
 
 
 }
 

  
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

GearVR, Using Swipe to control Camera in VR 0 Answers

Swipe and Joystick Together on Mobile 0 Answers

How can I make this "swipe w/ force"? Camera tilt/pan on swipe. 1 Answer

How to make swipe function? 1 Answer

Move Sword(GameObject) along a path with mouse with same speed 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges