I’m trying to do a nested for loop, but according to the ouput in the log, I’m never reaching the code.
The Debug.Log(“for”) is never being reached. I’m at a loss why.
There’s no errors, just not reaching the code.
protected virtual void attack()
{
for(int i=0; i<targets.Count; i++)
{
targets[i].dist = Vector3.Distance(transform.position, targets[i].transform.position);
Debug.Log("before for");
for(int cl = 0; cl< closestTargs.Count; cl++)
{
Debug.Log("for");
if(closestTargs.Count <= 0)
{
closestTargs.Add(targets[i]);
}
Debug.Log("end of first if");
if(targets[i].dist < closestTargs[cl].dist)
{
target = targets[i].gameObject;
}
Debug.Log("end of second if");
}
Debug.Log("out of for");
if(targets[i].dist > range)
{
targets.RemoveAt(i);
}
}
}