2D Path-finding with AStar in Godot 3.0

An image-heavy explanation of a general-purpose solution

Josef Frank
Sep 29, 2018 · 5 min read
Image for post
Image for post
The final product

Image for post
Image for post
You’re probably using the dark theme, huh?
Image for post
Image for post
We will fill these with entities later

Image for post
Image for post
Add a new child node
Image for post
Image for post
…of type Node
Image for post
Image for post
…name it “game”

Image for post
Image for post
Add a new scene
Image for post
Image for post
Add a tilemap
Image for post
Image for post
Naming the node
Image for post
Image for post
Create a new tileset
Image for post
Image for post
Open the new tileset
Image for post
Image for post
Add an item to this tileset
Image for post
Image for post
Expand index 0 and load a new texture
Image for post
Image for post
Load in the “navigation_map_point.png” tile
Image for post
Image for post
Return to the tilemap by pressing it
Image for post
Image for post
Press Ctrl+S to save, if you don’t know how to save the scene
Image for post
Image for post
Add a new script to the navigation_map
Image for post
Image for post
Accept the defaults
Image for post
Image for post
Pretty bland, huh?
Phew! That’s a tonne of code!
Image for post
Image for post
Glorious syntax highlighting

Image for post
Image for post
PIck the “Sprite” type
Image for post
Image for post
Name the node
Image for post
Image for post
Save the node in the player folder
Image for post
Image for post
Load a new texture
Image for post
Image for post
Select the asset in the player folder
I guess GitHub doesn’t like signals?
Image for post
Image for post
Code in game

Image for post
Image for post
Name this node “sidekick” instead
Image for post
Image for post
Pick the sidekick sprite
Image for post
Image for post
Save the scene in the sidekick entity folder
Image for post
Image for post
Save the file

Image for post
Image for post
navigation_map should be below everything else
Image for post
Image for post
The sidekick has to follow this
Image for post
Image for post
Save it in the root folder as game.tscn
Image for post
Image for post
The final script we need
Fairly simple code overall
Image for post
Image for post
Image for post
Image for post

Kitsch Digital

We make the games your mother warned you about

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store