Object placement systems that snaps to 2D TileMap grids in Godot 4 and follows defined build rules to determine whether placement is valid.
Video Tutorials & Project Updates
Tutorials Playlist
Project updates playlist
What this plugin does
- Creates a visual way of letting players choose where to place Godot scene objects into the game world with a visual preview and grid targeting tools.
- The targeting system snaps to the TileMap grid which means objects being placed will snap onto those grid positions.
- Lets you define the rules for when and how an object can be placed into the game world. Before an object can be placed, it must meet each building rule's requirements. You can also define your own rules by inheriting from the BuildRule base class.
- Provides optional base inventory (ItemContainer) class that can be used with the include SpendMaterialsRule for subtracting material resources from a user's inventory. A generic spending rule is also included if you want to write your own inventory class.
- A full working demo you can use as reference or base for your own game scenes. Feel free to reuse any UI components used in the demo.
What game types does this plugin work with?
- Top Down 2D Godot Games where levels are built with TileMaps
- NEW: Metroidvania / Sidescrolling Games made with TileMaps
- Works with all collision shape 2Ds and collision polygon 2Ds for generating placement collision shapes against the grid
I intend to get it working with side scrolling / platformer perspective games shortly after initial release of the plugin.
You can read more about the details of using this plugin in the project readme file or watch my video tutorials (highly recommended)
How to Use
- Download and add the .zip contents to your project in the directory addons/GridBuilding.
- Turn on the plugin in Project Settings -> Plugins tab.
- Add a GridTargetingSystem node to your main gameplay scene, either in the editor scene hierarchy or by instantiating the object
- Add a BuildingSystem node to your main gameplay scene, either in the editor scene hierarchy or by instantiating the object
- Add the grid_positioner.tscn scene to your node 2d game world parent. This should be the parent node where your game tilemap is a child of.
- Assign external dependencies to each system under the External Dependencies property group. You can do this either in the inspector or as your level nodes for targeting objects like the build system user (likely the main player character) through code.
- To trigger build mode, you call set_buildable_preview on the BuildingSystem. You need to define a placeable resource file which holds the settings for placing a scene object into the game.
- To make the system place the object into the game world, press the action(s) defined in the BuildingSystem for object placement. You set these up in the Godot project settings and then add the string names of those actions in the BuildingSystem inspector. By default ui_accept is used which you could test by pressing ENTER in a new project.
- To limit where and when a placeable scene can be instantiated, you must use BuildRules. Add rules you want to include for all placeables to the BuildingSystem and placeable object specific rules to each placeable resource file. You can read more below about build rules and what the default rules do.
- For tile collision indicators, you can start with the provided templates. Right click them to create an inherited scene and save it your own project. You can assign a different template scene to the rules that require them (NoCollisionsRule and ValidPlacementTileRule) to have different settings for each one. An indicator needs to have the mask layer of the collision object you want to create indicators for on the tilemap grid during building. So an indicator with mask 11 will find objects with collision layer 11 and create indicators for it. Only one indicator will be created for each grid position so be sure your indicator masks and target shapes don't conflict.