# GearVR Touchpad help

**URL:** <https://discussions.unity.com/t/gearvr-touchpad-help/635791>\
**Category:** XR\
**Tags:** XR\
**Created:** [August 8, 2016, 12:46pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791 "2016-08-08T12:46:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![syedzainnn\_1](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@syedzainnn\_1](https://discussions.unity.com/u/syedzainnn_1)\
**Post date:** [August 8, 2016, 12:46pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/1 "2016-08-08T12:46:37Z")

</div>

hello,  
i’m new to unity and i’m trying to use Touchpad in C# script to make simple movement either by swipes or single taps. Can anyone help with a basic script for this purpse?  
Thankyou in advance

---

<div class="post-metadata">

**Author:** ![Martinez-Vargas](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Martinez-Vargas](https://discussions.unity.com/u/Martinez-Vargas)\
**Post date:** [August 8, 2016, 1:38pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/2 "2016-08-08T13:38:00Z")

</div>

The touch panel of the Samsung works as the mouse of unity, and the tap functions as the click (INPUT) of unity

```csharp
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class RayCast2 : MonoBehaviour
{
    public Ray ray;
    RaycastHit hitInfo;
   

    void Start()
    {

    }

   
    void Update()
    {
        if (Input.GetButtonDown ("Fire1"))
        {
            Code/code/Accion
        }

        if (Input.GetKey (KeyCode.Escape))
        {
            //button functions as the Samsung Gear VR
        }
        ray = new Ray(transform.position, transform.forward);
        Debug.DrawRay (ray.origin, ray.direction*10, Color.blue);
        if(Physics.Raycast(ray, out hitInfo))
        {
            if(hitInfo.transform.CompareTag("sometag"))
            {
                //Object-tag
                if(Input.GetButtonDown("Fire1"))
                {
                    code
                }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![syedzainnn\_1](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@syedzainnn\_1](https://discussions.unity.com/u/syedzainnn_1)\
**Post date:** [August 8, 2016, 7:16pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/3 "2016-08-08T19:16:01Z")

</div>

Actually i tried this method but i couldn’t make the transform.translate() to make movement according to the swipes. Can you help with that?

---

<div class="post-metadata">

**Author:** ![Martinez-Vargas](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Martinez-Vargas](https://discussions.unity.com/u/Martinez-Vargas)\
**Post date:** [August 8, 2016, 7:30pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/4 "2016-08-08T19:30:34Z")

</div>

I do not understand your question friend.

---

<div class="post-metadata">

**Author:** ![syedzainnn\_1](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@syedzainnn\_1](https://discussions.unity.com/u/syedzainnn_1)\
**Post date:** [August 9, 2016, 7:11am UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/5 "2016-08-09T07:11:34Z")

</div>

if (Input.GetButtonDown (“Fire1”))  
{  
Code/code/Accion  
}

lets say i want my character to move to the point where the pointer was tapped on touchpad. how do i accomplish that?

---

<div class="post-metadata">

**Author:** ![Martinez-Vargas](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Martinez-Vargas](https://discussions.unity.com/u/Martinez-Vargas)\
**Post date:** [August 9, 2016, 1:30pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/6 "2016-08-09T13:30:47Z")

</div>

Hello, there are many ways to do this, one is launching a raycasts and when you give click to touch samsung, this will keep the position where coliciono lightning.  
the easiest way is transforming the position of the object you want to move to the mouse position, that the following code is done as samples-.

```csharp
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public GameObject particle;
    void Update() {
        if (Input.GetButtonDown("Fire1")) {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray))
                Instantiate(particle, transform.position, transform.rotation);
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Martinez-Vargas](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Martinez-Vargas](https://discussions.unity.com/u/Martinez-Vargas)\
**Post date:** [August 9, 2016, 2:02pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/7 "2016-08-09T14:02:38Z")

</div>

```csharp
using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour
{
    public GameObject SomeObject;
    public Ray ray;

    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Debug.DrawRay (ray.origin, ray.direction*100, Color.blue);
        if (Input.GetButtonDown("Fire1"))
        {
            if(Physics.Raycast(ray))
                Instantiate(SomeObject, ray.direction, transform.rotation);
        }
    }
}

```

You can print the raycast outside the input so you can see on the screen.

---

<div class="post-metadata">

**Author:** ![syedzainnn\_1](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@syedzainnn\_1](https://discussions.unity.com/u/syedzainnn_1)\
**Post date:** [September 4, 2016, 12:29pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/8 "2016-09-04T12:29:19Z")

</div>

thank you so much. i will try this

---

<div class="post-metadata">

**Author:** ![syedzainnn\_1](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@syedzainnn\_1](https://discussions.unity.com/u/syedzainnn_1)\
**Post date:** [September 10, 2016, 11:34am UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/9 "2016-09-10T11:34:05Z")

</div>

it says “object reference not set to the instance of an object”

---

<div class="post-metadata">

**Author:** ![Selzier](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/selzier/32/392348_2.png) [@Selzier](https://discussions.unity.com/u/Selzier)\
**Post date:** [September 11, 2016, 2:43pm UTC](https://discussions.unity.com/t/gearvr-touchpad-help/635791/10 "2016-09-11T14:43:19Z")

</div>

> [@syedzainnn\_1](#):
>
> lets say i want my character to move to the point where the pointer was tapped on touchpad. how do i accomplish that?

My Mobile VR movement pack has this example:  
[https://www.assetstore.unity3d.com/en/#!/content/69041](https://www.assetstore.unity3d.com/en/#!/content/69041)

I also have a lot of VR movement tutorials on my channel:

[https://www.youtube.com/watch?v=JmgOeQ3Gric](https://www.youtube.com/watch?v=JmgOeQ3Gric)
