Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

HexGrid library for Godot 4.0+

An asset by HugoEnzo
The page banner background of a mountain and forest
HexGrid library for Godot 4.0+ hero image

Quick Information

0 ratings
HexGrid library for Godot 4.0+ icon image
HugoEnzo
HexGrid library for Godot 4.0+

HexGrid library for Godot 4.0+ (based on redblobgames.com 's implementation)

Supported Engine Version
4.1
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

HexGrid_Godot_4.0

HexGrid library with functions based on www.redblobgames.com 's implementation:

  • Make an addons folder on your project's (res://) folder and then move HexMap folder to the addons folder
  • Navigate to your project settings -> plugins -> and then add the plugin to your project

Public variables and methods:

Variable -

var is_flat: Determines drawing style of flat or pointy topped hex

var size: A Vector2 of given hex size. x doesnt not have to equal y

var origin: The x/y position of the origin of the grid

Functions-

func add_hex(hex, data): Add new data to an unoccupied hex.

func move_hex(hex_old, hex_new): Move occupied hex to unoccupied location.

func remove_hex(hex): Remove an occupied hex

func get_hex(hex): Get data for a hex

func get_all_hex(): Get a dict of all hex data

func get_wall(hex, direction): Get wall data for a given hex

Rotation Transform Herlpers:

func rotate_hex_left(hex):

func rotate_hex_right(hex):

Pixel funcs and things useful to drawing.

func hex_to_pixel(hex): x,y for a given hex.

func pixel_to_hex(pos): Full hex for a given x,y

func round_hex(hex): Round fractional hex to full.

func hex_corner_offset(corner): Vector2 Offset for a given corner based on layout

func hex_corners(hex): Array of Vector2 locations to draw a full hex.

Neighbor and Distance Utility Functions

func neighbor_hex(hex, direction):

func diagonal_neighbor_hex(hex, direction):

func hex_length(hex):

func hex_distance(hex_a, hex_b):


   

HexGrid library for Godot 4.0+ (based on redblobgames.com 's implementation)

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
HexGrid library for Godot 4.0+ icon image
HugoEnzo
HexGrid library for Godot 4.0+

HexGrid library for Godot 4.0+ (based on redblobgames.com 's implementation)

Supported Engine Version
4.1
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers