Get which object has the minimum value with Mathf.Min

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;
    }
}

Hello there.

There is a little language barrier at play, and also I think you’re trying to impose a (likely odd) solution, instead of simply explaining what you’re actually trying to do. I couldn’t really understand what you need (I tried), so can you please repeat by literally describing the scenario where such a timer contraption plays a role?

Regarding your bolded question, you can always subtract numbers and compare them, but I’m sure you have reasons to believe this is not as simple as that.

If timeToFirstFixation < firstFixationTime

timeToFirstFixation selected