Home › Forums › Software Development › Can't use 2 Gaze aware objects › Reply To: Can't use 2 Gaze aware objects
using Tobii.Gaming;
using UnityEngine;
using System.Collections;
using System.IO.Ports;
[RequireComponent(typeof(GazeAware))]
public class SpinOnGaze : MonoBehaviour {
SerialPort serial = new SerialPort (“COM3”, 9600);
private GazeAware _gazeAware;
void Start()
{
serial.Open();
_gazeAware = GetComponent<GazeAware>();
}
void Update()
{
if (_gazeAware.HasGazeFocus)
{
transform.Rotate(Vector3.forward);
{ serial.Write(“e”);
}
}
}
}
If i just use one gameObject, the servo and the cube moves. But if I add a second object, with this line of code
using Tobii.Gaming;
using UnityEngine;
using System.Collections;
using System.IO.Ports;
[RequireComponent(typeof(GazeAware))]
public class SpinOnGazee : MonoBehaviour {
SerialPort serial = new SerialPort (“COM3”, 9600);
private GazeAware _gazeAware;
void Start()
{
serial.Open();
_gazeAware = GetComponent<GazeAware>();
}
void Update()
{
if (_gazeAware.HasGazeFocus)
{
transform.Rotate(Vector3.forward);
{ serial.Write(“e”);
}
}
}
}
I get a Null reference exception