0

I am trying to transform object into VR app using google cardboard sdk in Unity3d. I write a script and comparing input buttons on Update method. So my code is below.

void Update () {

    if (Input.GetButtonDown("Fire1"))
    {
        onObjectDown();
    }

    if (Input.GetButtonDown("Fire2"))
    {
        onObjectExit();
    }

    if (Input.GetButtonDown("Fire3"))
    {
        onObjectExit();
    }

    if (dragging)
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector3 rayPoint = ray.GetPoint(distance);
        transform.position = rayPoint;
    }
}

onObjectDown() & onObjectExit() method are as follows

public void onObjectDown()
{
    Debug.Log(name + " Game Object Down!");
    distance = Vector3.Distance(transform.position, Camera.main.transform.position);
    dragging = true;
}

public void onObjectExit()
{
    dragging = false;
    Debug.Log(name + " Game Object Exit!");
    GetComponent<Renderer>().material.color = originalColor;
}

This coding is perfectly working on play mode on desktop. But on emulator only onObjectDown is executing. This means only "Fire1" button is pressed. Is anyone know how to get input from button "Fire2" & "Fire3" via bluetooth controller ?

For reference, my input setting in project is as below

enter image description here

Galandil
  • 4,169
  • 1
  • 13
  • 24
Mayur Dusane
  • 367
  • 1
  • 8
  • 17

1 Answers1

0

Button 1 on Bluetooth controller you can initializing with Input.GetMouseButton(0) or Fire 1 because it simulate display tap. But the other controller button simulate (in my case) back button on Android device, so u can initializing with Input.GetKeyDown(KeyCode.Escape).

Zarko Ristic
  • 134
  • 4
  • 13
  • I am only able to get trigger from "FIRE 1" only. I am using [this controller](http://amzn.in/bf4JLsB). – Mayur Dusane Mar 29 '18 at 13:58
  • Try to use controller in other apps, what happens when you press that button? And do you make app for PC or Mobile device? Your input settings above is for PC and MAC, but GVR SDK is mainly intended for Android and iOS devices. – Zarko Ristic Mar 30 '18 at 14:37