Home Forums Game Integration Drawing game with Tobii eye tracker 5

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #21837
    Zachary Gray
    Participant

    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!

    #21847
    Grant [Tobii]
    Keymaster

    Hi @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.

    #24655
    Devin
    Participant

    This will be a very good and interesting game, will learn more about this papa’s games.

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