Search Unity

360 Virtual Tour - Switch using Joystick

Discussion in 'VR' started by siddhantchd, May 17, 2019.

  1. siddhantchd

    siddhantchd

    Joined:
    May 17, 2019
    Posts:
    9
    I am creating a 360 virtual tour for VR headset in Unity - I create sphere and fill it with panoramic photo as material. I create multiple such spheres.

    I want to configure my VR BOX joystick such that when I click one particular button on it I move to the next image.

    I was creating virtual tour according to this tutorial:


    Thank you for all comments.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,408
    call that same method they use to switch sphere, when button is pressed,
    upload_2019-5-17_23-23-42.png
    image from that video, it seems to be script SphereChanger,
    and method is ChangeSphere(targetsphere)
    with target sphere transform as parameter

    i think you can get button press from
    Code (CSharp):
    1. if (Input.GetButtonDown("Fire1"))
    https://docs.unity3d.com/ScriptReference/Input.GetButtonDown.html
     
  3. siddhantchd

    siddhantchd

    Joined:
    May 17, 2019
    Posts:
    9
    Thank you @mgear
    yes following that approach but how can i detect moving forward and backward spheres as i m not able to find that particular object ?
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,408
    not sure what you mean by 'moving forward and backward spheres as i m not able to find that particular object'?

    do you mean, you click 1 button to next sphere, and another button to go back to previous?
     
  5. siddhantchd

    siddhantchd

    Joined:
    May 17, 2019
    Posts:
    9

    yes sorry for the confusion
    this is exactly what i meant "click 1 button to next sphere, and another button to go back to previous"
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,408
    if you have already all the spheres in the scene,
    can create array of transforms from them:
    publicTransform[] allSpheres;
    int currentIndex=0; // keep track of which sphere we are in

    then using your buttons it would increment the currentIndex,
    and also need to check if can increase (go next) or decrease (go previous) it,
    then go to next sphere, using the current transform from the array:
    ChangeSphere(allSpheres[currentIndex])
     
  7. siddhantchd

    siddhantchd

    Joined:
    May 17, 2019
    Posts:
    9
    Thanks a lot @mgear exactly what i wanted

    Appreciate the help.