Over 11,000 five-star assets

Rated by 85,000+ customers

Supported by 100,000+ forum members

Every asset moderated by Unity

Home
Tools
Utilities
1/6
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.
Render pipeline compatibility
The Built-in Render Pipeline is Unity’s default render pipeline. It is a general-purpose render pipeline that has limited options for customization. The Universal Render Pipeline (URP) is a Scriptable Render Pipeline that is quick and easy to customize, and lets you create optimized graphics across a wide range of platforms. The High Definition Render Pipeline (HDRP) is a Scriptable Render Pipeline that lets you create cutting-edge, high-fidelity graphics on high-end platforms.
Unity VersionBuilt-inURPHDRP
2022.3.12f1
Compatible
Compatible
Compatible
Description

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);

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

Free Spot Finder 2D

(not enough ratings)
$5.99
Seat
1
Updated price and taxes/VAT calculated at checkout
Refund policy
This asset is covered by the Unity Asset Store Refund Policy. Please see section 2.9.3 of the EULA for details.
Secure checkout:
Supported payment methods: Visa, Mastercard, Maestro, Paypal, Amex
License type
File size
91.1 KB
Latest version
1.0.1
Latest release date
Apr 15, 2024
Original Unity version
2022.3.12
Quality assets
Over 11,000 five-star assets
Trusted
Rated by 85,000+ customers
Community support
Supported by 100,000+ forum members
Unity logo
Language
Feedback
Partners Program
Partners
USD
EUR
Copyright © 2025 Unity Technologies
All prices are exclusive of tax
USD
EUR