Index problem

Mar 7, 2013 at 4:57 AM
I'm trying to make a collision system for my game, however I am encountering a problem when trying to get the layers of my map file.

I get an error at this line
collision = map.Layers[3];
It says "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

I'm not sure why, I don't know if it's a problem with my map file or something in my code, any help would be great!
Mar 7, 2013 at 7:52 AM
Layer indices are zero-based. So if your map has, say, 3 layers, you can access them via indices 0, 1 and 2 (not 1, 2 and 3).
Mar 7, 2013 at 9:21 AM
Yea, I figured it out, there was a problem somewhere else in my code causing that, thanks!