I have a 2-part question:
1: I have 2 rectangles, A and B. B is a wall and A is moving. My simple logic here is every time A moves, it moves based on some (x,y) offset and then checks if it collided with something. If it is colliding with something, roll back bit by bit in the opposite direction until it is not colliding anymore.
The problem here is if A moves in large chunks, it might skip over B entirely.
The intended behavior is to find out where A should be when it first touched one of B's faces and then roll back to that point and apply collision resolution.
2: What if B is moving as well?
What I'm currently doing to side step this issue is to create large enough collision boxes and make sure moving objects do not exceed some maximum. This approach seems like it will be limiting in the future.
I assume there is a mathematical way to solve this but I wasn't able to find any answers from my searches. Any tips/suggestions are greatly appreciated.
Thanks!