Hi all,
I’m making a 2D side scrolling platformer, where the platforms are effectively a 2D array of tiles rendered in much the same way as a standard 2D top-down game (0, 0) top left hand corner to (mapWidth * tileWidth, mapHeight * tileHeight) which is the bottom right hand corner. The player can land on tiles, depending on whether they’re set in the array, or walk into them, or bang their head on them, etc.
Gravity is acting on the player, so if they aren’t standing on a tile, they’ll keep falling faster, until they reach the end of the tile map, then they’ll fall forever. Everything’s going fine, but I’m determining collisions much in the same way as I’ve been doing in the top down games, whereby I divide the player’s position + delta movement, divide each of the player’s surrounding corners by the tileWidth and tileHeight, then loop through them, checking if they’re passable and if one isn’t, I stop the player from moving in that axis.
That’s all fine for those games because the player doesn’t move by a significant amount at a time, but obviously when gravity’s introduced the player begins to clip through tiles, because the tile features between the player’s position and the player’s position + delta movement.
Are there any standard methods of solving this problem as at the moment, when the player’s falling more than, say, 50 blocks, they can clip straight through entire platforms.
If anyone could give me any tips on this I’d appreciate it.