Skip to content

9thAzure/Complex_Shape_Creation

Repository files navigation

Complex Shape Creation

Regular Polygon 2D icon

GitHub Release GitHub License GitHub Issues or Pull Requests GitHub Downloads (all assets, all releases)

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.

Installation

There are 2 ways to download the plugin:

Godot Asset Library download

  1. In the Godot editor, go to the AssetLib tab.
  2. Search for the "2D Regular Polygons" addon.
  3. Select and click install (and subsequent installs.).

Zip-file download.

  1. Go to the Releases page.
  2. Download the zip file in Assets section of the wanted release.
  3. Extract the complex_shape_creation folder from the zip file and put it in the addons folder in the target project. Create the addons folder if it does not exist yet project.

Once downloaded, the addon can be enabled in Project > Project Settings > Plugins.

Quick Tutorial

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.

Nodes

Currently, there are 4 nodes:

Properties

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 of 1 = circle and 2 = 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 than 0 or greater than size 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 of 0 with their own value.

Functions

Currently, functions used for creating shapes are split across the multiple nodes added. Most of them are in RegularPolygon2D. Some exceptions are:

The get_* functions create shapes and returns a new PackedVector2Array. All other functions modify the array passed in as the argument.

License

This addon is available under the MIT license, which is in the addon's folder. A copy is available in the root folder.

Plugins / Packages Used

This addon uses several external packages for unit testing: