Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Detect gaze by RayCast with Hologram

Hi,

I am study Hololens Academy tutorial 101E. In the "Gaze" section, the tutorial use the following code to detect if the gaze is on the hologram object

if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))

I am not sure what exactly a "hologram" object is.

I have bought a board game assets from Assert Store. The structure of the assets is like

-Game set folder
----Meshes folder
--------Material folder
--------(x)Game board
------------(x)Game piece 1
------------(x)Game piece 2

But (x), I meant a small blue cube icon ( I am not exactly sure what this icon means in Unity). I then drag the "Game board" to my scene hierarchy. When I build the project and run it in holelens, I can see the game board and game pieces. But the Raycast detection was not triggered when I looked at these pieces.

To debug the problem, I then created some 3D cube with Unity and added them to my scene hierarchy. When I looked at these cubes in hololens, the Raycast detection was triggered.

I am wondering what the difference between game piece and 3D cube is and why Raycast was not triggered with game piece.

Thank you very much.

Fireman

Best Answer

Answers

  • @DeckTwelve, you are right. Thank you very much.

    Fireman

  • @DeckTwelve Besides using a box collider, it there anything else I can do to make the RayCast first?

    My board game App works like this: if user gazes at a piece, the App will move the piece higher a little bit in the y direction. And if a piece is at a high position and user speaks a command "move", the App will move that piece forward.

    I recently find my App is not very responsive. I am wondering if the RayCasting is taking too much resource...

    Thank you very much.

    Fireman

  • I cam calling RayCast in update() method. Is this too much?

  • Hi @Fireman,

    Raycasting in Update() is fine. However, you didn't say in which gameobject's update method you're calling it. Based on your description of the problem I'm wondering if you might be raycasting more than you need to, like once per piece, which would impact performance.

    Take a look at the profiler (Window > Profiler) while your game is running and drill-down into BehaviourUpdate looking for Physics.raycast. How many calls per frame? For gaze you only need to raycast once per frame. Here's an example of what to look for in the profiler.

    If you can post a screenshot of what you find in the profiler I'll do my best to help you debug the performance problem.

    -Matt

  • @DeckTwelve is the profiler in Unity or VS?

  • evanjamesevanjames
    edited May 2016


    @DeckTwelve
    I apologize for being a novice but how did you get pass chapter 2? How do I edit the GazeManager.cs and Cursormanager.cs file, and edit it to perform the following tasks:
    1.Perform a physics raycast,
    2.Store the position and normal of the raycast intersection,
    3.If the raycast did not hit anything, set the position and normal to defaults.

    gokk.PNG 145.2K
Sign In or Register to comment.