Free Spot Finder 2D View on Asset Store (opens in new tab)

Package details

Latest version
1.0.1
Last updated
First released
Unity version
2022.3.12 or later
Package size
91 KB
Files
5
Favorites
1
Views in the past week
3

Price tracking

Last checked
Tracked since
Lowest recorded
$5.99 on

Keywords

Free Spot Finder 2D

by curio124 (opens in new tab)

1 rating, too few to average

Highly performant area analyzer capable of detecting remaining unoccupied spots in circular and rectangular 2D areas to safely place new objects to the scene without overlapping.

Price $5.99

Buy on Asset Store (opens in new tab)

Affiliate link · Purchases support this site

Price history

Last 6 months

USD
Price history for Free Spot Finder 2D, 6 months Current $5.99; lowest $5.99; highest $5.99 in this period. $0 $5 $10 Jun Jul Aug Sep Oct Nov

Asset preview

1 / 5

Free Spot Finder 2D screenshot 1

Free Spot Finder 2D screenshot 1

About this asset

Highly preformant detection algorythm encapsulated in the single class with 3 main capabilities:

1. calculate % of occupation in rectangular or circular area,

2. retrieve random free spot from rectangular or circular area,

3. check if defined rectangular or circular area is unoccupied or not.

Used algorythm is 5-20x faster than using any Physics.Cast approach and works either with internal shapes or existing colliders. Area is analyzed and random free spot retrieved usually within few miliseconds! Works only in 2D space.

Supported concepts:

- fixed boundaries to retrieve free spot

- padding for placed object not to overlap with occupied areas

- rectangular or circular detection area

- flexible resolution of the detection algorythm

- rectangles, circles, ellipses and points as occupied areas

- Collider2D (any) as occupied areas

- rotation and scaling of Collider2D

- DebugDraw functions to display results of analysis

Provided class is very easy to use and every public function, method and property is well documented. Free spot can be retrieve in 3 very easy steps:

1. create an instance with preffered settings (or use properties later)

        var scanArea = new ScanArea2D(boundariesSize: new Vector2(40, 20));

2a. add occupied areas manually by providing shapes:

        scanArea.AddPoint(new Vector2(4, 2));

        scanArea.AddCircle(new Vector2(-2, 1), 2);

        scanArea.AddRectangle(new Vector2(1, -3), new Vector2(3, 2));

2b. and/or enable detection of existing colliders for occupied spots

        scanArea.ignoreAllColliders = false;

3. request new random available spot for object of defined size

        Vector2 freeSpot =  scanArea.GetRandomFreePositionForRectangle(objectSize, areaCenter, areaRadius);

From the publisher's Asset Store listing.

Technical details

All logic is encapsulated in the signle class ScanArea2D, that can be placed anywhere in your project folder structure. Instance of this class can be created either ad-hoc just before requesting free spot, or can be maintained for longer duration for better performance in specific cases.

Class doesn't have any specific dependencies on external libraries, it requires just System and UnityEngine.

Exposed analytical methods:

- GetOccupation

- GetRandomFreePosition

- GetRandomFreePositionForCircle

- GetRandomFreePositionForRectangle

- TryGetRandomFreePosition

- TryGetRandomFreePositionForCircle

- TryGetRandomFreePositionForRectangle

- IsFree

Exposed shape methods:

- AddPoint

- UpdatePoint

- AddCircle

- UpdateCircle

- AddRectangle

- UpdateRectangle

- RemoveShape

Exposed setting methods:

- SetBoundaries

- RemoveBoundaries

Exposed properties:

- boundariesCenter

- boundariesSize

- baselineResolution

- fixedResoluion

- ignoreAllColliders

- ignoreAdvancedColliders

Compatibility

Render pipelines supported in each Unity version
Unity version Built-in URP HDRP Custom
2022.3.12f1 Compatible Compatible Compatible Compatible

As listed on the Asset Store.