0 votes

According to godot docs:

Rect2 consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.

If it's used for fast overlap tests, when should i use it over something like an area2d or a physics server intersect_shape call?

Godot version 3.3.4
in Engine by (29 points)

1 Answer

+2 votes
Best answer

It is for simpler uses than collision testing. For example check if player is within screen rectangle. Check if enemy is within a square of distance from player. Check if unit is within borders of rectangle drawn by dragging mouse.

by (6,369 points)
selected by

Oh so it's for simple overlap testing.
One last thing is, if I had a large amount of square shapes that I wanted to detect overlapping for, would you recommend using PhysicsServer or Rect2?

I would use collision shapes, geometry or physics querries. Rect2 is only good for detecting single overlapping points with its has() method.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.