I don’t understand how we know that the object we’re triggering is of type target because the object is just a sphere with a collider.
public List<Target> targets = new List<Target>();
private void OnTriggerEnter(Collider other)
{
if (!other.TryGetComponent<Target>(out Target target)){return;}
targets.Add(target);
}
private void OnTriggerExit(Collider other)
{
if (!other.TryGetComponent<Target>(out Target target)){return;}
targets.Remove(target);
}