Grid updated in a diagonal line (or didn't update visually correctly)

I resolved the issue but just bringing it up in case it happens for anyone else.

I followed all the steps, and then when I went to test it, at the final step, to see if it was updating (continously, not just after pressing T) it displayed only the diagonal grid positions , 0,0 and 1,1 and then 2,2, so on, depending on the move distance.

And if I moved in the X column 0, 1, to 0,2 etc it wouldn’t change at all.

Had no idea what mistake I had made. Well… It was this code here.

public void ShowValidGridPositionList(List<GridPosition> gridPositionList)
foreach (GridPosition gridPosition in gridPositionList)
        gridSystemVisualSingleArray[gridPosition.x, gridPosition.z].Show();

I had

gridSystemVisualSingleArray[gridPosition.x, gridPosition.x].Show();

gridPosition.x TWICE!

I have done similar things so many times in the last 4 years its unreal(even in unity ha).

So much so that now my eyes can actually see it in code(sometimes)

It’s why I shared my mistake AFTER figuring out what the problem was, instead of whining about it and asking others to help. Because hopefully it happens to someone else and this answer can help them. And if not, hopefully just by figuring it out and posting it, I can remember it, if this (or something similar!) ever happens to me again.

I’m still very new to arrays, so a simple error. But a serious one!

1 Like

Privacy & Terms