• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Tile_get_index return weird value!

B

bilouw

Guest
Hi guys,

I have a tile collision system who works fine. Just a little problem, when i use the function tilemap_get_at_pixel, combined with the function tile_get_index, the return value is fine (1, 2, 3 in fonction on the tile i am), but sometimes it returns number like "41, 23", but i don't have tile with this index, so the game crash, because or array out of range. Do you see why?

the code :
var pos = tile_get_index(tilemap_get_at_pixel(tilemap, _x, _y));

Thanks.
 

Yal

šŸ§ *penguin noises*
GMC Elder
Try checking if the tilemap exists before you try to get the index of it, perhaps? (You'll need to add an extra step for this to get the tilemap into its own variable so you can check it and then get its index)
 
B

bilouw

Guest
I checked the 3 variables used as argument for the function tilemap_get_at_pixel, and everything is fine (tilemapid always the same, x and y always in range). I deleted and reset the tile where the error occured in my room, and now the error is not anymore here ... its very strange, it's seems to be related with a transformation on the tile (flip or other), but i don't know why my function return me a wrong index value in that case, because the tile_get_index function should extract the index correctly of the blob data.
 
Top