Spawns bullets randomly inside the limits of a custom polygon you draw in the editor canvas.
<aside> 💡 IMPORTANT : this pattern requires you to draw a shape in the editor. The “curve” property of the SpawnPattern node will be saved into this resource in order to spawn the bullets on the points you drew.
</aside>
<aside> 💡 You don’t have to close the polygon, meaning you can draw a square with just 3 lines and the last one will just be assumed to exist.
</aside>
Center pos : position of the center of your shape. The positions of the points on the curve will be saved relative to that center and not the center of the map. This allows you to draw (= store) the shape anywhere on the map, out of the way of your actual game.
Grid Spawning : Bullets will spawn in a grid like pattern instead of randomly. Imagine a grid where x and y are the spacing between the vertical and horizontal lines, the bullets would spawn on the intersections.
Tries Max : when bullets are spawned at random positions inside the area, the code tries random positions, in the limits of the orange rectangle around your shape, and then checks if it’s inside the polygon. It technically can result in an endless loop. For some shapes more than others. This property allows you to control the maximum amount of trials until the code gives up on searching for a valid position.
Pooling : choosing random positions as explained above takes a lot of resources. For the sake of optimisation, this will only be done when the game loads for the 1th time. A set of different positions are registered and random ones will be picked each time a bullet spawns. This pre-determined set has a size of Nbr of bullets multiplied by Pooling.
Polygon : (hidden) polygon representing the area. Can be calculated using ☄️curve_to_polygon(pattern, curve:Curve2D)
: takes a curve2D and turns it into a polygon (PackedVector2Array)