1

Using the Windows HoloToolKit and Unity 2017, I have the "menu" scene set up and I have the "tour" scene set up. I'm just stuck trying to make the gaze-based interaction that will advance from the menu to the tour.

I feel like it's not too hard, but I'm spinning my wheels (and I'm a beginner in Unity). I basically want there to be 3D cube that says "look here" and that triggers the next scene.

I just need a very simple UX so people can put the headset on, know exactly what to do, watch the video, and then it will return to the menu.

Blauharley
  • 4,186
  • 6
  • 28
  • 47

1 Answers1

0

Though I'm not that familiar with the HoloKit API, I'd assume that your camera is aligned with where the player is looking. In that case, you can send a raycast out from the camera and then check if it hits the cube. If the raycast does, then you can change the scene, like so:

public void Update()  {
    RaycastHit hit = null;
    if (Physics.Raycast(transform.position, transform.forward, hit) && hit.transform.gameObject.name == "cubeName") {
        SceneManager.LoadScene("nextScene");
    }
}

Of course, you might not want the cube to load the scene the instant they lay eyes upon it. In that case, you could keep track of how long they look at it, and then change scenes after looking at it for a certain amount:

public float lookTime;
public void Update()  {
    RaycastHit hit = null;
    if (Physics.Raycast(transform.position, transform.forward, hit) && hit.transform.gameObject.name == "cubeName") {
        lookTime += Time.deltaTime;
    }
    else {
        lookTime = 0;
    }
    if(lookTime > 1000) {
         SceneManager.LoadScene("nextScene");
    }
}

This script, when attached to your camera, will raycast from the camera and check if what it hits is named cubeName. Then, it will add the current amount of time change to lookTime. When lookTime reaches 1000 milliseconds, or one second, it will load the scene nextScene.

Douglas Dwyer
  • 562
  • 7
  • 14
  • Thank you. I'm now experiencing a bug where I cannot get the headset to work with Unity anymore. Your code seems like it will work, but I never got it to work now with this bug. – Luka Starmer Feb 12 '18 at 19:46