First of all, if you know a better way to do what I want to achieve please don't hesitate to suggest your own method.

What I want to do is the classic area selection in RTS games, which player drags his mouse to draw a rectangle and units inside rectangle become selected.

At this point, I have two ideas:

  1. A dedicated gameObject with a trigger BoxCollider2D.
  2. Detecting overlaps with Physics2D.OverlapArea method.

In the first method, the gameObject will get resized on the fly while the user drags and by using collision control the objects get selected.

In the second method starting point and end point of the area is being recorded and script draws an OverlapArea using these two coordinates.

Which one would be more effective in terms of performance?

Thanks in advance.


2 Answers 2


I would definitely go with the second method. In this manner, you don't have to have anything firing in your physics engine, or have to deal with disabling/enabling colliders when you are not using them.

The second method also has the added benefit of having Point1 and Point2 parameters, which coincide with your drag/draw selection interface. You are going to start dragging at Point1 and release at Point2.

Using the second method for this mechanic is the way to go.


I would definitely look at this link: RTS style Unit selection

It is very well done. You will need to do a little bit of optimalization yourself tho.

I use it in my RTS game and it works much better than the other solutions i tried.

  • 1
    \$\begingroup\$ This answer currently leans very heavily on the link. If the URL for that article ever changes, or becomes unavailable, then users viewing your answer won't be able to glean the solution you're proposing. Please consider editing to include at least a rough summary inside your answer itself, so that it can stand on its own, and include the link for credit & further reading. \$\endgroup\$
    – DMGregory
    Apr 29, 2018 at 16:06
  • \$\begingroup\$ Will do when I get home :) fair point! \$\endgroup\$ Apr 29, 2018 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .