How to find the complete intersection of two Rect2 from any beginning

Godot Version

Godot 3.5.3

Question

I need to make a selection of two Rect2 as in strategy games, get_rect().intersects only works when the starting point is to the left and above, get_rect().encloses has an inversion, that is, the starting point should be to the right and below, but how to find the intersection if the starting point somewhere in the top right and bottom left?

You could use Rect2.abs() on both rects before calculating the intersection.

1 Like

Thank you! That helped :slight_smile: