I can’t figure out what the error is. I can comment out the for loops and the rest of the code is fine. But when I put it back the error happens.
Errors:
Use of unassigned local variable x
Use of unassigned local variable y
Here is the erroring code:
for( int x; x < dmgCol.forcesApplied.Count; x++) // Error Here
{
for( int y; y < defenseApplied.Count; y++) // Error Here
{
if(dmgCol.forcesApplied[x].forceType + defenseApplied[y].forceType == 0.0f)
{
temp += dmgCol.forcesApplied[x].forceCur * (defenseApplied[y].forceCur - .05f);
Debug.Log(temp);
break;
}
if(y == defenseApplied.Count - 1)
{
temp = dmgCol.forcesApplied[x].forceCur;
Debug.Log(temp);
}
}
}