I have a simple rectangle-tile collision scheme set up, and it works beautifully.
The only problem is when you start falling off of a ledge. Your speed reaches the point where the change in Y/X each frame is large enough for you to clip into solid objects and glitch about.
Basically my setup is as follows:
To start with, the player's position has its velocity added to it, so the player is now at the place he would be next frame if no collisions happen. The list below is just a single function, checkIntersectTiles(Vector2 maskPos);
- Calculate tiles around the character to check.
- Loop through tiles, including those inside the bounding tiles.
- Check the player's collision rectangle against each of these tiles.
- If there's an intersection, move the largest offending axis out of the tile, then set that axis velocity to 0.
- Continue checks.
When you clip into the ground, you jitter around inside, as my algorithm attempts to move you outside the tile that is most colliding with you.
My solution: Check each position from the player's pos, to the player's pos + velocity. I'm stuck on that bit.
Can anyone give me a hand?