A simple fence plugin for Godot Engine 4.x. Makes the building of fences easy, and dynamic.
I created this plugin for use in a small game project I'm working on. I wanted to have a simple and flexible solution for drawing fences that auto-connect, and could not find any simple solutions. Such solutions may exist, but Google (as usual these days) failed me, so I decided to implement it myself. If anything, I learnt something from it :)
This will be the easiest method, if you don't mind updating manually
- Download the latest release
- Open or extract the
.zip
- Copy folder to the
/addons/
folder of your Godot project
Caution
Make sure to preserve parent directory. Path should be /addons/Picket
, or similar
- In the Godot Editor, click
Project
->Project Settings
->Plugins
-> Click theEnable
tick next to the Picket plugin
Warning
I cannot guarantee the below working as expected, I have only recently began utilizing this methodology during development of this addon, I utilized a slightly advanced function within git, submodules. The benefit of this, I believe, is that you can simply git submodule update --remote
to fetch upstream changes.
- In your project directory,
git init
, if you do not already have a git repository - Create the
/addons/Picket/
directory - Execute
git submodule add [email protected]:mikael-ros/picket.git /addons/Picket
- In the Godot Editor, click "Project" -> "Project Settings" -> "Plugins" -> Click the
Enable
tick next to the Picket plugin
Note
This plugin has only been developed with 1:1 aspect ratio in mind. Other ratios may work, but are not officially supported
This plugin uses two separate textures; one for your fence, and one for the posts.
Post should be centered in the middle of it's texture, but can be of any size you like.
Should be centered vertically, and should take up the width of the texture.
-
Add the Picket node to your scene
-
Add a TileSet in the properties of Picket
-
In the "Tile Set" tab, add the two textures. Ideally, fence first, post second
note: if textures are not in that order, change the indices in the Texture positions tab of Picket.
-
In the "Tile Map" tab, paint tiles as you normally would
Load demo.tscn
into a Godot project where you have installed and enabled Picket.
You can adjust the position at which the fences intersect. This shifts the position, and can be useful if you want to have padding.
Tip
If you still want to adjust the position manually, use the Origin positions. Any adjustment of the normal Position vector will be overwritten otherwise.
You can adjust where in the tile the posts are placed. The addon will dynamically fill in posts where absent, so spacing is consistent.
You can rotate the fence direction by first enabling Positioning -> Direction interpretation -> Direction interpretation mode
Additionally, you can enable "unsupported" rotation (eg. rotation that is 90 degrees or 270 degrees) by ticking the corresponding box. These are regarded as "unsupported" because they look weird, but may be useful in certain situations.
This is the only supported rotation mode at the moment. Fence is rotated by using the controls in the Tile Map editor.
Note
At the moment, there is no preview for rotation, as this is difficult to implement.
Currently, tile shapes are not supported beyond "Square". Non-uniform fences aren't supported yet either, so fences can only be straight.
If you desire certain functionality within this plugin, or encounter a bug, feel free to add an issue and I will get around to it when time allows - or you can contribute it yourself, see the contribution guidelines
This plugin reads the tile map data, and paints five child TileMapLayers. Two for the fences - one for vertical connections and one for horizontal connections - and three for the posts (vertical, horizontal, and stationary).
The cursor exists on another temporary layer, which only exists in the editor. While this could just have been a sprite, the idea is to permit future preview implementations.
While the amount of layers may seem excessive, this is necessary for offsets and anchors to work. If you'd like, you're welcome to contribute a better solution :)
For more technical details, read the code contained in this repository.