Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Feature Request Detect when VR user looks away from an object?

Discussion in 'VR' started by VRBytes, Feb 24, 2022.

  1. VRBytes

    VRBytes

    Joined:
    Feb 24, 2022
    Posts:
    11
    Hello,

    I'm new to unity3d development!

    I am building a VR education app for Quest 2 and basically want to detect when a user looks away from an object (count how many times they look away, and start a timer for how long they look away).

    I want to store & collect these metrics for analysis (so store them in a database perhaps?) Is this even possible?

    Essentially, I want to detect when a user is looking away from the content to see if they are being distracted by the environment etc!
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,836
    could use Vector3.Dot (to check if look away)
    https://docs.unity3d.com/2018.4/Documentation/Manual/UnderstandingVectorArithmetic.html
    https://docs.unity3d.com/ScriptReference/Vector3.Dot.html

    Or this, if object goes totally outside of view
    https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameInvisible.html

    to save the data..could send using webrequests, if you have server to receive it:
    https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.html

    it could be possible to use unity analytics to collect those events, but i don't have experience/info on those..

    there used to be heatmaps feature, to see where user visited etc. which sounds like good way to collect view direction data, but i dont know if its still available
    https://docs.unity3d.com/Manual/UnityAnalyticsOverview.html *NOTE: legacy old docs
     
    VRBytes likes this.
  3. VRBytes

    VRBytes

    Joined:
    Feb 24, 2022
    Posts:
    11
    Thank you so much for all the links!

    I didn't expect to get a response so fast, thanks for the help mgear!
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,836
    VRBytes likes this.
  5. VRBytes

    VRBytes

    Joined:
    Feb 24, 2022
    Posts:
    11