Home › Forums › Game Integration › Unity SDK with tobii Eye X
Tagged: Using tobii Eye X with Unity SDK
- This topic has 13 replies, 3 voices, and was last updated 6 years, 2 months ago by Alex [Tobii].
- AuthorPosts
- 22/07/2018 at 05:27 #8616Rasa BhattaraiParticipant
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.22/07/2018 at 05:28 #8617Rasa BhattaraiParticipantSorry,
I forgot to attach code in my above questionprivate 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.
23/07/2018 at 13:07 #8622Grant [Tobii]KeymasterHi @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.
23/07/2018 at 16:42 #8628Rasa BhattaraiParticipantHello,
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 ?
24/07/2018 at 14:23 #8632Alex [Tobii]ParticipantHi! gazePoint.Screen.x and gazePoint.Screen.y represent gaze point (the point on the screen you are currently looking at) in Screen (pixel) coordinates.
25/07/2018 at 09:09 #8636Rasa BhattaraiParticipantHello 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
25/07/2018 at 11:32 #8640Alex [Tobii]ParticipantI 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#tobiiapisetcurrentuserviewpointcamera25/07/2018 at 15:10 #8642Rasa BhattaraiParticipantHello,
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 you27/07/2018 at 13:22 #8655Alex [Tobii]ParticipantCould you please try explicitly calling
https://tobii.github.io/UnitySDK/scripting-api#tobiiapisetcurrentuserviewpointcamera07/08/2018 at 17:48 #8699Rasa BhattaraiParticipantHello 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 (IEnumerable
1 points, UnityEngine.Camera camera) (at Assets/Tobii/Framework/Internal/HitTestFromPoint.cs:100)
Tobii.Gaming.Internal.HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints (IEnumerable1& hitInfos, IEnumerable
1 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)`07/08/2018 at 20:50 #8702Alex [Tobii]ParticipantHi!
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.htmlSolution 2:
In your component add:void Start() { TobiiAPI.SetCurrentUserViewPointCamera(Camera.current); }
09/08/2018 at 06:17 #8707Rasa BhattaraiParticipantHello 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
PlayerThe 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.
16/08/2018 at 09:31 #8732Grant [Tobii]KeymasterHi @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.
08/10/2018 at 17:52 #8888Alex [Tobii]ParticipantHi @rasa !
The bug must be fixed in the new release, which is available for testing
https://github.com/Tobii/UnitySDK/releases/tag/4.0.0Fixed warnings and errors in Unity 2017 and 2018
Updated underlying API
Added TobiiAPI.IsConnected()
Fixed build for non-Standalone platforms
Removed subscribe/unsubscribe functions - AuthorPosts
- You must be logged in to reply to this topic.