So I've been working on a tile based platformer (actually a Jump n Bumb rip). I have vectors, delta time, and all that stuff working, the only problem is I'm not sure how to do the collision. All tiles have a solid boolean value, and I can check if the player is actually IN the tile just fine. The problem is I don't know how to make the player stop just on top of the terrain, or stop them from moving straight into/through the terrain when it lags. I can do this fine when its just 4 direction movement, but the vectors are just messing all my attempts up.

Thanks in advance, you guys are always so helpful.

When the program lags, your position may skip well beyond the point where a collision could have taken place. So what you need to do is think of the path you travel between two loop iterations as a line segment and then see if that line segment intersects with any surface (which are also line segments). For line segments within a two dimensional plane this means solving a relatively simple equation.

When your path intersects with a surface, you can then relocate your object to the intersection point, instead of to the end of its path.

Stephan van Hulst wrote:When the program lags, your position may skip well beyond the point where a collision could have taken place. So what you need to do is think of the path you travel between two loop iterations as a line segment and then see if that line segment intersects with any surface (which are also line segments). For line segments within a two dimensional plane this means solving a relatively simple equation.

When your path intersects with a surface, you can then relocate your object to the intersection point, instead of to the end of its path.