Advertisement
Guest User

Untitled

a guest
Feb 15th, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. public static class RectExtensions
  2. {
  3. // Both rectangles and the player positions
  4. public static bool Intersects(this Rect r1, Rect r2, Vector2 p1, Vector2 p2, out Rect area)
  5. {
  6. r1 = new Rect(r1.x + p1.x, r1.y + p1.y, r1.width, r1.height);
  7. // r2 is facing left
  8. r2 = new Rect(r2.x - p2.x, r2.y + p2.y, r2.width, r2.height);
  9. return r1.Overlaps(r2, true);
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement