Search Unity

GearVR player movement with touchpad

Discussion in 'AR/VR (XR) Discussion' started by Frostyfrogfromrussia, Mar 31, 2019.

  1. Frostyfrogfromrussia

    Frostyfrogfromrussia

    Joined:
    Mar 31, 2019
    Posts:
    1
    Hello, I am beginner developer in unity, and I have a problem with touchpad, which I want to use in movement camera. I've read some topics and in all of them offer something like the following code.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class OVR_PlayerMove : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     private float velocity = 5.0f;
    8.  
    9.     private int direction = 100;
    10.     private CharacterController controller;
    11.     private Transform head;
    12.     private Transform body;
    13.  
    14.     void Start()
    15.     {
    16.         controller = GetComponent<CharacterController>();
    17.         head = Camera.main.transform;
    18.         body = transform.Find("Body");
    19.     }
    20.  
    21.     void Update()
    22.     {
    23.         if (Input.GetMouseButton(0))
    24.         {
    25.             controller.SimpleMove(head.transform.forward * velocity * direction * Time.deltaTime);
    26.             body.transform.rotation = Quaternion.Euler(new Vector3(0.0f, head.transform.eulerAngles.y, 0.0f));
    27.         }else
    28.         if (Input.GetMouseButtonUp(0) && direction == -100)
    29.         {
    30.             direction = 100;
    31.         }
    32.         if (Input.GetMouseButtonDown(0))
    33.         {
    34.             if (Input.GetAxisRaw("Mouse X") < 0)
    35.             {
    36.                 direction = -100;
    37.             }
    38.             else
    39.             {
    40.                 direction = 100;
    41.             }
    42.         }
    43.     }
    44. }
    I created a camera and attached this code. When I start the game in Unity, I click the mouse and everything is OK, the camera moves. But when I start the game on the phone, and I click on the touchpad, nothing happens. Maybe someone faced such a problem, or I forgot to set something up?

    https://imgur.com/a/U8wBudB - screen with unity
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    The touchpad (I assume you mean on the GearVR controller) is not a mouse.
     
    Frostyfrogfromrussia likes this.