I have two rectangles, one is moving and one is stationary. I have the size of both rectangles and both the current coordinates of the moving rectangle and the coordinates of where it wants to go. It will move in a straight line. With this information, what is the most effective way to find if the two boxes will collide on the path. Is it more efficient to do this or to move the box a small amount each frame and do a collision detection each time?
Share
Since one of the rectangles is stationary, one way to do this is to create a polygon of the path travelled by the moving rectangle, which can be done using only its initial and final positions:
Path polygon:
Then use a normal polygon collision detection algorithm between the stationary rectangle and the path polygon.