- This topic has 1 reply, 2 voices, and was last updated 2 years, 5 months ago by Grant [Tobii].
- AuthorPosts
- 07/07/2022 at 19:47 #22174Varun RamakrishnanParticipant
I am currently trying to move an object with the user’s gaze point but am having trouble converting the gaze point to a world space position.
My scene setup is:
– An eye image on a canvas that follows the user’s gaze (so that the user can see what they’re looking at)
– A cube on a plane that the user is supposed to move with their eyes.The objective is for the user to move the cube with their eye after looking at it. I change the cube’s material color once it
HasGazeFocus
and that works without any issues so I know that theGazeAware
component and Tobii are working correctly.void Update() { transform.position = Camera.main.ViewportToScreenPoint(Tobii.Gaming.TobiiAPI.GetGazePoint().Viewport); }
The canvas image has the above in a script attached to it and moves correctly but the cube is always at the same position.
I have tried using
GetGazePoint().Screen
followed bycamera.ScreenToWorldPoint
as well as ‘GetGazePoint().Viewportfollowed by
camera.ViewportToWorldPoint` but neither of them seem to change the cube’s position.Right now I’m moving it in 2D along the XY plane so I fix the z-coordinate to a constant.
Any pointers on how I could make the cube move with the eye would be appreciated.
11/07/2022 at 12:58 #22247Grant [Tobii]KeymasterHi @vramakrishnan, did you check the values of the gaze point as reported in the sample script we produced @
https://developer.tobii.com/pc-gaming/unity-sdk/scripting-api/#tobiiapigetgazepoint
using Unity.Engine; using Tobii.Gaming; public class ExampleClass : MonoBehaviour { void Update() { GazePoint gazePoint = TobiiAPI.GetGazePoint(); if (gazePoint.IsRecent()) // Use IsValid property instead to process old but valid data { // Note: Values can be negative if the user looks outside the game view. print("Gaze point on Screen (X,Y): " + gazePoint.Screen.x + ", " + gazePoint.Screen.y); } } }
It would be an idea to see what values are being produced to see how to convert them to your own desired coordinate system.
- AuthorPosts
- You must be logged in to reply to this topic.