Home Forums Game Integration Unity SDK with tobii Eye X

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #8616
    Rasa Bhattarai
    Participant

    Hello all,
    I am just a beginner in unity and using tobii. I am creating a game (A ball moving around in circle along x and z axis with y- axis being constant).
    I want to record every points of x, y and z co-ordinates as seen by the eye tracker (Tobii Eye X – the one I have) as the circle begins to move (Or when I start the Play button). i.e I want tobii Eye X to record all the points and save it in a file.
    My questions are:-
    How to integrate my game with tobii ? I have alredy imported tobii unity sdk package (It has all examples like 02a_simple gaze selection, 01_GazePointData etc. But how do I make this code correspond with my game ?
    Also, How do I continuously store the values of the x, y and z position every second in a file ?

    Please I really need help. The documentation does not clearly show how to link that script with my game object.
    Thank you in advance.

    #8617
    Rasa Bhattarai
    Participant

    Sorry,
    I forgot to attach code in my above question

    private void MoveBall()
        {
            x = Mathf.Cos(timeCounter * Mathf.PI/180) * radius;
            y = 0.5f;
            z = Mathf.Sin(timeCounter * Mathf.PI / 180) * radius;

    }`

    This is the code for circle equation and are the 3 data points.

    #8622
    Grant [Tobii]
    Keymaster

    Hi @rasa, thanks for your query. It should be a quite straightforward procedure to integrate the Tobii Gaze Data into your game.

    We have created a tutorial for you to follow online @ https://tobii.github.io/UnitySDK/manual#integrate-the-sdk-into-your-game

    Which will guide you through all the various steps required to integrate your game with Tobii. Please kindly go through this tutorial and get back to us should have any further questions on the matter.

    With regards to saving the co-ordinates obtained from the eye tracker to a file, this is expressly prohibited by the Unity SDK licence agreement and requires the purchase of an ‘analytical licence’ to do. Any long term storage of gaze data is not permitted without this special licence.

    You can read more @ https://analyticaluse.tobii.com/?utm_source=developer.tobii.com

    Please let us know if we can be of any further help to you. Best wishes.

    #8628
    Rasa Bhattarai
    Participant

    Hello,

    Thank you for the suggestion.
    I looked into the tutorial and did the following steps. Would you clarify if the steps that I took to perform the gaze point calculation is correct or not ?
    1) Imported the Tobii Unity SDK and all the assets and folders into the same project that I am working on (Into my Unity folder).
    2) To my gameComponent(A sphere), I added a script with the following code:

     void Update()
        {    
            GazePoint gazePoint = TobiiAPI.GetGazePoint();
            if(gazePoint.IsRecent())
            {
                value_x = gazePoint.Screen.x;
                value_y = gazePoint.Screen.y;
                print("Gaze point on screen (X,Y): " + value_x + ", " + value_y);
            }
         }

    My gameComponent keeps on moving in a circle continuously. While looking at the gameComponent throughout the time period when the game mode is on in unity, Is the gazepoint given by the above code, the (x,y) coordinates of the gameComponent on the screen ?

    #8632
    Alex [Tobii]
    Participant

    Hi! gazePoint.Screen.x and gazePoint.Screen.y represent gaze point (the point on the screen you are currently looking at) in Screen (pixel) coordinates.

    https://tobii.github.io/UnitySDK/manual#gaze-point-data

    #8636
    Rasa Bhattarai
    Participant

    Hello Tobii team,

    I wanted to use the GazeAware Component in my Unity game. I used it by going to the steps :-> Add Component(In the inspector window) -> Eye Tracking -> Gaze Aware.
    I ran the program after attaching tobii eye X device but I get this error.

    NullReferenceException: Object reference not set to an instance of an object
    Tobii.Gaming.Internal.HitTestFromPoint.CreateRaysFromPoints (IEnumerable1 points, UnityEngine.Camera camera) (at Assets/Tobii/Framework/Internal/HitTestFromPoint.cs:100)
    Tobii.Gaming.Internal.HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints (IEnumerable1& hitInfos, IEnumerable1 points, UnityEngine.Camera camera, Single distance, Int32 layerMask) (at Assets/Tobii/Framework/Internal/HitTestFromPoint.cs:44)
    Tobii.Gaming.Internal.SingleRaycastHistoricHitScore.FindObjectsInGaze (IEnumerable1 gazePoints, UnityEngine.Camera camera) (at Assets/Tobii/Framework/Internal/SingleRaycastHistoricHitScore.cs:126)

    What is the problem here ? How should i fix it?

    Thank you

    #8640
    Alex [Tobii]
    Participant

    I think your project doesn’t have Main camera. Please try using this method to set active camera to use for object selection:
    https://tobii.github.io/UnitySDK/scripting-api#tobiiapisetcurrentuserviewpointcamera

    #8642
    Rasa Bhattarai
    Participant

    Hello,
    My project does have the main camera.
    I do not know what is wrong. As per the documentation, I simply added by going to Add Component(In the inspector window) -> Eye Tracking -> Gaze Aware. Before adding this everything works, but after I add this, it gives this error.
    Please help.
    Thank you

    #8655
    Alex [Tobii]
    Participant
    #8699
    Rasa Bhattarai
    Participant

    Hello Tobii Team,

    I do not understand the above mentioned solution. Could you provide a detailed method of how to call it explicitly: Where should i call this ?

    I received the same error while adding GazeAware component to my ‘Player(GameObject)’. I have a ball moving in circle when I make the Play button on in unity. But as you said my project does not have ‘Main camera’: How is it possible to see the ball moving without the main camera ? Am I missing something to understand here. Please help me clarify what should i do to remove this error and make GazeAware component work ?

    NullReferenceException: Object reference not set to an instance of an object
    Tobii.Gaming.Internal.HitTestFromPoint.CreateRaysFromPoints (IEnumerable1 points, UnityEngine.Camera camera) (at Assets/Tobii/Framework/Internal/HitTestFromPoint.cs:100)
    Tobii.Gaming.Internal.HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints (IEnumerable1& hitInfos, IEnumerable1 points, UnityEngine.Camera camera, Single distance, Int32 layerMask) (at Assets/Tobii/Framework/Internal/HitTestFromPoint.cs:44)
    Tobii.Gaming.Internal.SingleRaycastHistoricHitScore.FindObjectsInGaze (IEnumerable`1 gazePoints, UnityEngine.Camera camera) (at Assets/Tobii/Framework/Internal/SingleRaycastHistoricHitScore.cs:126)
    Tobii.Gaming.Internal.SingleRaycastHistoricHitScore.GetFocusedObject (IEnumerable`1 lastGazePoints, UnityEngine.Camera camera) (at Assets/Tobii/Framework/Internal/SingleRaycastHistoricHitScore.cs:55)
    Tobii.Gaming.Internal.GazeFocus.UpdateGazeFocus () (at Assets/Tobii/Framework/Internal/GazeFocus.cs:138)
    Tobii.Gaming.Internal.TobiiHost.Update () (at Assets/Tobii/Framework/Internal/TobiiHost.cs:156)`

    #8702
    Alex [Tobii]
    Participant

    Hi!

    Solution 1:
    Add main camera to the scene:
    – Add camera object to the scene.
    – Tag it as Main camera as in
    https://answers.unity.com/questions/173870/how-to-make-a-camera-a-main-camera.html

    Solution 2:
    In your component add:

    
    void Start()
    {
      TobiiAPI.SetCurrentUserViewPointCamera(Camera.current);
    }
    
    #8707
    Rasa Bhattarai
    Participant

    Hello Tobii team,

    I did everything as told but nothing seems to be working. Would you please help me out to solve this problem ?

    public GazeAware _gazeAwareComp;
    void Start()
        {
            TobiiAPI.SetCurrentUserViewPointCamera(Camera.current);
            _gazeAwareComp = GetComponent<GazeAware>();
        }
    
        void Update()
        {
          if (_gazeAwareComp.HasGazeFocus)
            {
             // Some code
            }
        }

    My hierarchy window is like this:
    Main Camera
    Directional light
    Ground
    Player

    The Main Camera is also enabled.

    When I play the button, the ball starts moving in a circle and the camera works fine. I did everything as suggested by you. I added GazeAware component in my Player game object and the code above. But it still shows the same error.

    Sorry for this same question. But i am having real trouble using gazeaware.

    #8732
    Grant [Tobii]
    Keymaster

    Hi @rasa, may I ask if you have had any progress since the last communication? According to colleagues, it should be enough to follow the advice above to get going.. I wonder if there is a chance you can test on another system just in case of some file corruption? thanks.

    #8888
    Alex [Tobii]
    Participant

    Hi @rasa !

    The bug must be fixed in the new release, which is available for testing
    https://github.com/Tobii/UnitySDK/releases/tag/4.0.0

    Fixed warnings and errors in Unity 2017 and 2018
    Updated underlying API
    Added TobiiAPI.IsConnected()
    Fixed build for non-Standalone platforms
    Removed subscribe/unsubscribe functions

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.