Hello everyone,
I have three gameobjects with a rising timer. At a certain time (when I hit the space key), each of the counters stop. This is how I got the counters working (attached code). I would like to know which object has the minimum value for “timeToFirstFixation” timer (which is the time that I spend until a select that object for the first time).
Basically, I would like to know which game object was first selected.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnMouseOverBehavior : MonoBehaviour
{
[Header("Materials")]
public Material originalMaterial;
public Material newMaterial;
[Header("Timer")]
public float timeToFirstFixation; //Tiempo que transcurre hasta que miramos esta AOI
public float firstFixationTime; //Tiempo empleado durante la primera fijación en esta AOI
public float totalFixation; //Tiempo de fijación total en esta AOI
private float counter;
private float _counter;
void Start()
{
#region Contadores a 0
totalFixation = 0;
firstFixationTime = 0;
timeToFirstFixation = 0;
counter = 0;
_counter = 0;
#endregion
}
void Update()
{
if (counter == 0 && _counter == 0)
{
timeToFirstFixation += Time.deltaTime;
}
if (counter == 1 && _counter == 0)
{
firstFixationTime += Time.deltaTime;
}
}
private void OnMouseEnter()
{
gameObject.GetComponent<MeshRenderer>().material = newMaterial;
counter = 1;
}
private void OnMouseExit()
{
gameObject.GetComponent<MeshRenderer>().material = originalMaterial;
counter = 0;
_counter = 1;
}
private void OnMouseOver()
{
totalFixation += Time.deltaTime;
}
}