Free Spot Finder 2D
curio124
$6.59
(no ratings)
Date |
Price |
---|---|
日時 |
価格($) |
02/15(2024) |
6.59 |
11/26(2024) |
6.59 |
Jump AssetStore
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.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 analysisProvided 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);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- IsFreeExposed shape methods:- AddPoint- UpdatePoint- AddCircle- UpdateCircle- AddRectangle- UpdateRectangle- RemoveShapeExposed setting methods:- SetBoundaries- RemoveBoundariesExposed properties:- boundariesCenter- boundariesSize- baselineResolution- fixedResoluion- ignoreAllColliders- ignoreAdvancedColliders