How do you fix OverflowException: Number overflow

I am following the Unity Learn tutorial for procedural caves and have just completed the second and third videos. The problem is that when I press play the caves do not appear. There are no errors coming up in Visual Studio but in Unity I am getting the error OverflowException: Number overflow:

I am pretty sure that it is all written correctly, I could be wrong but I have checked it multiple times. I clicked the error and it took me to this line:

I am not sure what is wrong. So if anyone could explain it to me and how to fix it that would be great.
Thank you.

Hi, the only thing that would explain this error is if nodeCountX or nodeCountY are = 0.

In that case you’re trying to create an array of size -1, which results in an error for obvious reasons.

In other words, the map parameter you’re sending to the SquareGrid method is probably not initialized.