Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
A optimized procedural hexagonal sphere generator for Godot 4, written in C#. It generates a dual-graph spherical grid composed of hexagons and exactly 12 pentagons.
Hexasphere Generator for Godot 4 (C#)
A procedural hexagonal sphere generator for Godot 4, written in C#. It generates a spherical grid composed of hexagons and exactly 12 pentagons. This project is an optimized port of the Unity implementation by Em3rgencyLT, tailored specifically for Godot.
How to Use
1. Via the Godot Inspector
- Add the
HexasphereDemonode to your 3D scene. - In the Inspector, configure the three main parameters:
- Radius: Controls the overall size of the generated sphere in 3D space.
- Divisions: Controls the density of the hex grid (higher values mean more hexagons).
- Hex Size: A clamped value between
0.01and1.0. Setting it to1.0makes tiles perfectly touch each other. Lowering it (e.g.,0.95) creates clean, visible gaps between individual tiles.
2. Via C# Scripting
(You can also find a better implementation in the HexasphereExample.cs script)
using Godot;
using Godot.Hexasphere;
public partial class MyPlanet : Node3D
{
private Hexasphere _hexasphere;
public override void _Ready()
{
// Initialize a sphere: radius = 10.0, divisions = 4, tile size = 0.95
_hexasphere = new Hexasphere(10f, 4, 0.95f);
GD.Print($"Planet generated with {_hexasphere.Tiles.Count} tiles!");
// Access a specific tile (e.g., the first one)
Tile randomTile = _hexasphere.Tiles[0];
// Get its exact 3D position to spawn a building or unit
Vector3 spawnPosition = randomTile.Center.Position;
// Iterate through neighbors for pathfinding, AI, or cellular automata
foreach (Tile neighbor in randomTile.Neighbours)
{
// Handle neighbor logic here
}
}
}
Core Architecture
The plugin completely separates pure mathematical data from Godot's rendering engine:
Hexasphere.cs— The main grid manager. It handles the initial icosahedron creation, manages subdivision logic, caches unique vertices using a spatial hash grid, and exposes the finalTileslist and rawMeshDetails.Tile.cs— Represents an individual cell on the sphere (either a hexagon or one of the 12 pentagons). It holds references to its boundary points, its center, and a list of its directNeighbours. Includes built-inToJson()serialization.Face.cs— An internal data structure used to track triangular faces during the icosahedron subdivision phase. It calculates centers and handles fast adjacency checks via unique integer IDs.Point.cs— Represents a 3D vertex on the sphere. It generates unique incremental integer IDs for $O(1)$ comparison performance and contains logic to sort faces in a clockwise/counterclockwise ring to guarantee correct mesh normals.MeshDetails.cs— A lightweight data container holding raw vertex and triangle arrays, ready to be fed directly into Godot'sArrayMesh.
A optimized procedural hexagonal sphere generator for Godot 4, written in C#. It generates a dual-graph spherical grid composed of hexagons and exactly 12 pentagons.
Reviews
Quick Information
A optimized procedural hexagonal sphere generator for Godot 4, written in C#. It generates a dual-graph spherical grid composed of hexagons and exactly 12 pentagons.