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.
Options

How to gaze single object countinues 3 minutes then and then execute OnGazeEnter function ?

HI,

i want to gaze continues 3 minutes of single game object then then execute OnGazeEnter function from GazeManager UpdateRaycast(). how can i handle this please help .thanks in advance.

private void UpdateRaycast()
{
// Get the raycast hit information from Unity's physics system.
int hitcount = 0;
RaycastHit hitInfo;
Hit = Physics.Raycast(gazeOrigin,
gazeDirection,
out hitInfo,
MaxGazeDistance,
RaycastLayerMask);

        GameObject oldFocusedObject = FocusedObject;
        // Update the HitInfo property so other classes can use this hit information.
        HitInfo = hitInfo;

        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;
        }
        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;
        }

        // Check if the currently hit object has changed
        if (oldFocusedObject != FocusedObject)
        {
            if (oldFocusedObject != null)
            {
                oldFocusedObject.SendMessage("OnGazeLeave", SendMessageOptions.DontRequireReceiver);
            }
            if (FocusedObject != null)
            {
                FocusedObject.SendMessage("OnGazeEnter", SendMessageOptions.DontRequireReceiver);
            }
        }
    }~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks,
Ankit sangani

Best Answer

  • Options
    HoloSheepHoloSheep mod
    Answer ✓

    @Ankit09_Sangani

    If I understand correctly, you only want the OnGazeEnter message to be sent out after the user continuously stares at the same object for 3 minutes straight.

    Sounds like you just need to declare a global variable GazeStartTime of type System.DateTime.
    Also declare another one called GazeDuration of type System.TimeSpan.
    Set that variable to System.DateTIme.Now on the first detection of the user gazing at any object.
    Then calculate GazeDuration = System.DateTime.Now - GazeStarted
    Test if GazeDuration.Minutes > 3 before sending the OnGazeEnter message.

    You can decide how you want to handle the condition of when the gaze hit does not hit a hologram and either reset the GazeStartTime for each missed hit if you don't want the user to look away from the object, or ignore misses if you are more concerned about the user not looking at a new object in the last three minutes.

    HTH.

    Windows Holographic User Group Redmond

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

Answers

  • Options
    HoloSheepHoloSheep mod
    Answer ✓

    @Ankit09_Sangani

    If I understand correctly, you only want the OnGazeEnter message to be sent out after the user continuously stares at the same object for 3 minutes straight.

    Sounds like you just need to declare a global variable GazeStartTime of type System.DateTime.
    Also declare another one called GazeDuration of type System.TimeSpan.
    Set that variable to System.DateTIme.Now on the first detection of the user gazing at any object.
    Then calculate GazeDuration = System.DateTime.Now - GazeStarted
    Test if GazeDuration.Minutes > 3 before sending the OnGazeEnter message.

    You can decide how you want to handle the condition of when the gaze hit does not hit a hologram and either reset the GazeStartTime for each missed hit if you don't want the user to look away from the object, or ignore misses if you are more concerned about the user not looking at a new object in the last three minutes.

    HTH.

    Windows Holographic User Group Redmond

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

Sign In or Register to comment.