using UnityEngine;
using System.Collections;
using Tobii.EyeTracking;
using System;
using Tobii.EyeX.Framework;


[RequireComponent(typeof(GazeAware))]

public class ArmRotation: MonoBehaviour {

    public int rotOffset = 00;

    // Update is called once per frame
    private GazeAware _gazeAware;

    Transform parent;
    void Awake() {
        _gazeAware = GetComponent<GazeAware>();
        
        parent = GetComponentInParent<Player>().transform;
    }
    void Update() {
        //if(_gazeAware.HasGazeFocus) {
          //  Debug.Log("has gaze");
            Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - parent.position; //sub'ing pos of player from the mouse pos
            difference.Normalize(); //making all values (sum of vector) equal to 1

            float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg; //finding angle between mouse and x axis
            transform.rotation = Quaternion.Euler(0f, 0f, rotZ + rotOffset);
       // }
    }


}
