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.

Cursor gets stuck on Object

WzrdWzrd
edited June 2016 in Questions And Answers

Currently testing out the cursor management and Gaze in the Hololens Emulator. It seems like the cursor gets stuck on the object. Here's some of my code:

        if (Hit)
        {
            // If the raycast hits a hologram, set the position and normal to match the intersection point.
            Position = hitInfo.point;
            Normal = hitInfo.normal;
            lastHitDistance = hitInfo.distance;
            focusedObject = hitInfo.collider.gameObject;
            //focusedObject.transform.Rotate(0, 0 * Time.deltaTime, 0, Space.World);

        }
        else
        {
            // If the raycast does not hit a hologram, default the position to last hit distance in front of the user,
            // and the normal to face the user.
            Position = gazeOrigin + (gazeDirection * lastHitDistance);
            Normal = gazeDirection;
            focusedObject = null;
        }

        if (Hit == engine)
        {
            holoComm.SetActive(true);
            if(Hit == holoComm)
            {
                GUI.SetActive(true);
            }
        }

        else
        {
            // If the raycast does not hit a hologram, default the position to last hit distance in front of the user,
            // and the normal to face the user.
            Position = gazeOrigin + (gazeDirection * lastHitDistance);
            Normal = gazeDirection;
            focusedObject = null;

            //focusedObject.transform.Rotate(0, speed2 * Time.deltaTime, 0, Space.World);
        }

Best Answer

Answers

  • @Wzrd do you have a collider on your object?

    If so where is it on your Hierarchy and where are the Cursor Manager and Gaze Manager components in comparison?

    What are these modifications to the GazeManager UpdateRaycast intended to do?
    Have you stepped through the code to see how it is behaving and if there are any errors or failures occurring?

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • How will this code ever evaluate to true:
    if(Hit == holoComm)
    given it is nested inside this code:
    if (Hit == engine)
    unless engine == holoComm?

  • @HoloSheep The object has an Box Collider, even though it's not necessary.. Does this affect the cursor? The GazeManager is inside a Manager who contain also an Interactible script. The CursorManager is separate from this. @timg I figured out the code did not make any sense, nor gave any results, so thats fixed.

  • It's obviously some code error, because the cursor seems fine now. However, the objects wont become active on Gazing.. Any suggestions?

  • WzrdWzrd
    edited June 2016

    I found the solution, and simplified the code a bit:

        if (this.gameObject == GameObject.Find("InfoCube"))
        {
         GameObject.Find("GUIv2").transform.localScale = new Vector3(0.02f, 0.2f, 0.8f);
    
        }
        else
        {
            GameObject.Find("GUIv2").transform.localScale = new Vector3(0.0f, 0.0f, 0.0f);
        }
    

    Found out that setActive() does not read inactive objects on load, so I used transform.localScale to edit the scale on Gaze. Works like a charm.

Sign In or Register to comment.