Home › Forums › Software Development › Get Eye-screen-coordinates and match it with a Unity game object
Tagged: Unity
- This topic has 18 replies, 8 voices, and was last updated 5 years ago by Grant [Tobii].
- AuthorPosts
- 01/11/2019 at 07:02 #12222pepitoParticipant
Hi, I need urgently a code to MOVE my object with my gaze point. On my game I move the object in the same position as the mouse is moving. The object it’s limitated on the space (I don’t know if this is relevant):
public Rect movementLimits = new Rect(-7, 0, 14, 10);
But I don’t know how to actually move the object with the eye tracker, I don’t know if I have to transform the coordinates or if I have to use a command on the player behaviour scrpit. Because when I use the eye tracker normally, without unity, transforms into the cursor automatically. But when I start the game, it dissapear.
Please I need someone to help me urgently.01/11/2019 at 10:06 #12228Grant [Tobii]KeymasterHi @stefy001, you can try assigning the object position to TobiiAPI.GetGazePoint().Screen
But please bear in mind that the gaze point is not highly accurate and has inherent jitters due to the biological nature of human eye movement so it should not be used as direct mouse replacement.. you would need to introduce some kind of fixation filter or movement buffer to make the action smooth.
But please do try it out and let us know how you get on.
05/11/2019 at 19:57 #12258pepitoParticipantOkey I will try (I think I already tried it) but I don’t know WHERE I have to put that command, and you mean that I have to put the mouse posittion command UNDER that line?
06/11/2019 at 10:22 #12262Grant [Tobii]KeymasterHi@ stefy001. I am afraid Without knowing your scene setup, it is difficult to give you an exact syntax, but perhaps this snippet can be useful for you.
void Update() { var gaze = TobiiAPI.GetGazePoint().Screen; transform.position = Camera.main.ScreenToWorldPoint(new Vector3(gaze.x, gaze.y, 10)); }
Let us know how that helps.
- AuthorPosts
- You must be logged in to reply to this topic.