MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Tilemap A* Pathfinding

Smart pathfinding for tilemaps that lets sprites calculate routes around walls and follow paths automatically.

sprite follow path

Problem it solves

You generated a path using pathfinding and now you want an enemy or companion sprite to smoothly walk along that route.

What this block does

Makes a sprite move through an array of tile locations one by one at a specified speed. If the sprite starts inside a wall or slightly off the path, it navigates or teleports to the nearest path tile before continuing.

The block

sprite $sprite follow path $path || speed %speed block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite that should follow the path.
pathtiles.Location[]locationTilesThe list of tile locations the sprite will move through.
speednumber50The movement speed in pixels per second.

Example

let mySprite = sprites.create(img`.`, SpriteKind.Enemy)
let myPath = scene.aStar(tiles.getTileLocation(0, 0), tiles.getTileLocation(9, 7))
scene.followPath(mySprite, myPath, 50)

Add the extension

Add github:jwunderl/arcade-tilemap-a-star to your project, or open: Import arcade-tilemap-a-star.