An addon for the Godot Engine which adds several functions for creating and modifying shapes, and a few nodes that uses those functions for creating visuals or for creating collision shapes.
These functions and nodes are written in GDScript to make them universally compatible.
They are exposed to C# via wrapper classes in the ComplexShapeCreation
namespace.
Note
Most of the functions for modifying shapes have a slightly different signature in C# compared to GDScript. Since they rely on the shape being passed by reference, something that isn't maintained during interop, the C# equivalents returns the shape instead.
There are 2 ways to download the plugin:
- In the Godot editor, go to the AssetLib tab.
- Search for the "2D Regular Polygons" addon.
- Select and click
install
(and subsequentinstall
s.).
- Go to the Releases page.
- Download the zip file in Assets section of the wanted release.
- Extract the
complex_shape_creation
folder from the zip file and put it in theaddons
folder in the target project. Create theaddons
folder if it does not exist yet project.
Once downloaded, the addon can be enabled in Project
> Project Settings
> Plugins
.
This is a short introduction to how the addon works.
More in depth documentation can be found the wiki or the documentation within the scripts, which is accessible within Godot editor's Script tab.
Currently, there are 4 nodes:
- RegularPolygon2D <
Polygon2D
- General purpose node for drawing shapes. - SimplePolygon2D <
Node2D
- counterpart to RegularPolygon2D that only draws simpler shapes. - StarPolygon2D <
Polygon2D
- Version of RegularPolygon2D for drawing stars. - RegularCollisionPolygon2D <
CollisionShape2D
- Node for creating both regular and star collision shapes.
Every node share similar properties with similar effects. They also generally do the same thing if they are named as a parameter in one of the functions used for creating shapes.
vertices_count
- Determines the kind of shape used. Usually, a value of1
= circle and2
= line.size
- Determines the size of the shape, from the center to the outer vertices.offset_rotation
- Determines the rotation of the created shape.width
- Determines the thickness of the shape. Usually, values smaller than0
or greater thansize
creates the full shape.drawn_arc
- Defines the arc where the shape is created, leaving a gap where the arc ends.corner_size
- Enables and controls the size of rounded corners.corner_smoothness
- Determines how many lines make up a rounded corner. Nodes replace a value of0
with their own value.
Currently, functions used for creating shapes are split across the multiple nodes added. Most of them are in RegularPolygon2D. Some exceptions are:
- a simplified version of
get_shape_vertices
is in SimplePolygon2D. widen_polyline
andwiden_multiline
are in RegularCollisionPolygon2D.get_star_vertices
is in StarPolygon2D.
The get_*
functions create shapes and returns a new PackedVector2Array
.
All other functions modify the array passed in as the argument.
This addon is available under the MIT license, which is in the addon's folder. A copy is available in the root folder.
This addon uses several external packages for unit testing:
- GUT (Godot Unit Test) (Godot addon)
- Chickensoft.GoDotTest (Nuget package)
- Shouldly (Nuget package)