Home › Forums › Game Integration › Drawing game with Tobii eye tracker 5
Tagged: game design
- This topic has 2 replies, 3 voices, and was last updated 5 months ago by Devin.
- AuthorPosts
- 28/04/2022 at 20:51 #21837Zachary GrayParticipant
Hello all, I am new to Unity and using C#. I have made a drawing game where you can draw a line by pressing down the mouse button but I intend this to be created with the eye; where the eye tracker will see where I am looking and it will generate the line on the screen instead of using the mouse. I am aware that the line might be jittery and inaccurate, but that doesn’t matter!
There is a game object within my scene with a script (called LineGenerator) attached as a component, here is the piece of code that is attached:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class LineGenerator : MonoBehaviour
{
public GameObject linePrefab;Line activeLine;
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
GameObject newLine = Instantiate(linePrefab);
activeLine = newLine.GetComponent<Line>();
}if (Input.GetMouseButtonUp(0))
{
activeLine = null;
}if (activeLine != null)
{
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
activeLine.UpdateLine(mousePos);
}
}
}The “linePrefab” stored in the public variable “GameObject” is a game object (stored in my prefab folder) with a line renderer attached.
I have the Unity SDK downloaded and this might have the capability to do what I’d like it to, but I am fairly unfamiliar with that as well. Help would be tremendously appreciated!
04/05/2022 at 12:59 #21847Grant [Tobii]KeymasterHi @zakg, the Tobii XR SDK comes with several sample scenes that should demonstrate clearly how to access the gaze streams .. please check them out and let us know how you get on. Best Wishes.
02/07/2024 at 01:55 #24655DevinParticipantThis will be a very good and interesting game, will learn more about this papa’s games.
- AuthorPosts
- You must be logged in to reply to this topic.