I’m not sure the correct term but I’m looking to simply place an object’s position based on the count of the loop.
The spacing here being the X axis.
0: Middle
- Right/ + 5f
- Left/ - 5f;
- Right/ + 10f;
- Left /- 10f;
An attempt:
int loopIndex = 0;
foreach(EnemyData i in enemiesInCounter){
int modifier = 5 * loopIndex;
if(loopIndex % 2==0){
modifier = -5 * loopIndex;
}
Debug.Log(Vector2.right * modifier);
Vector2 position = Vector2.right * modifier + (Vector2.up * 2.5f);
SpawnEnemyFromData(i,position);
loopIndex++;
}
The problem here is that loop count 2 is set to -10f instead of 5f;