Git Product home page Git Product logo

godot_2d-hex_nav_demo's Introduction

2D Hexagonal Map Navigation Demo(4.x)

This is an example of implementing hexagonal TileMap navigation in Godot.

In the 4.x version, the cells of the TileMap can be set to hexagons. Hexagons can dock with six other tiles, so they differ from rectangular grids in terms of grid coordinates and pathfinding.

This project provides a solution.

First, we generate an AStar2D instance and add a new point at the given location of all given identifiers; Then we obtain each grid and its adjacent points in turn, and connect each grid with its adjacent points; Finally, we return a list of all cells adjacent to the cell at coordinates, which is the navigation path.

This project is based on the 3.x version of the same name!(https://godotengine.org/asset-library/asset/1888). At that time, the TileMap format only supported rectangles, so the author created many methods to handle hexagonal calculations. The internal principles of this version are different from those of the 3.x version.

Screenshot

2D 六边形地图导航演示(4.x)

在4.x版本,TileMap的单元格可以设为六边形。六边形可以对接另外六个瓦片,因此在网格坐标以及寻路上都与矩形网格不同。

这个项目提供了一个解决方案。

首先我们生成一个AStar2D实例,并在所有给定标识符的给定位置添加一个新点; 然后我们依次获取每个网格及其相邻点,并将每个网格与相邻点连接起来; 最后我们返回与 coords 处的单元格相邻的所有单元格的列表,这个列表就是导航路径。

这个项目参考了同名下的3.x版本,当时的版本TileMap格式仅有矩形,因此作者建立了很多方法来处理六边形的计算。本版本内部的原理与3.x版本并不相同。

godot_2d-hex_nav_demo's People

Stargazers

tkcrow avatar Human Grass avatar

Watchers

aorui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.