Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Android bluetooth controller

Discussion in 'Android' started by masterchop, Mar 14, 2016.

  1. masterchop

    masterchop

    Joined:
    Oct 9, 2015
    Posts:
    39
    Hello

    i am using the BT Controller that come with the SVR which has arrows and a few buttons, they work when i use this code:
    if(Input.anyKey){
    Debug.Log("anykey"+(string)Input.inputString);
    //Debug.Log(Input.GetAxisRaw);
    text.text="Anykkeyismoved"+(string)Input.inputString;
    }

    which returns the key i used but how do i use those keys?
    it returns 45 or 24 just numbers how do i use those in android. arrows work but not the other buttons
     
  2. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    Did you configure the axis in the Input settings?
    What is SVR? :)
     
  3. masterchop

    masterchop

    Joined:
    Oct 9, 2015
    Posts:
    39
    Hehe sorry SVR = Snail VR which is a chinease cardboard that tries to simulate the GearVR, not even close but it has good lenses and it comes with a bluetooth controller.

    The bt controller i think its not a normal one, as the it has multiple buttons that dont do anything at anytime but this code reports that they have feedback:

    if(Input.anyKey){
    Debug.Log("anykey"+(string)Input.inputString);
    //Debug.Log(Input.GetAxisRaw);
    text.text="Anykkeyismoved"+(string)Input.inputString;
    }


    This is working for movement:
    voidUpdate(){
    if(Input.GetKey(KeyCode.RightArrow))
    {
    transform.Translate(newVector3(speed*Time.deltaTime,0,0));
    }
    if(Input.GetKey(KeyCode.LeftArrow))
    {
    transform.Translate(newVector3(-speed*Time.deltaTime,0,0));
    }
    if(Input.GetKey(KeyCode.DownArrow))
    {
    transform.Translate(newVector3(0,0,-speed*Time.deltaTime));
    }
    if(Input.GetKey(KeyCode.UpArrow))
    {
    transform.Translate(newVector3(0,0,speed*Time.deltaTime));
    }
    }

    This works too:

    if(Input.GetKeyDown(KeyCode.Escape)){
    //PauseGame();
    Shooting = true;
    }


    But the question is how can i use the other buttons that i can get with the 1st code?