Change direction only after hitting obstacle [and few more aspects...]


We saw A* Pathfinding Project on the Asset Store and were wondering whether it could be useful for our project.

To make it simpler to describe, take the mobile game " Tomb of the Mask: Color" ( or similarly “Amaze” (

Key points:
A. Only 90 degrees paths allowed
B. Turns only after hitting an obstacle (as by the example games, after hitting a wall)

By searching the forum, point A is addressable by setting the graph’s connections to 4.

For point B, Manhattan heuristic seems not suitable for this requirement.
Using example 15 from the demo scenes, here’s a screenshot:

As highlighted by the dotted circle, the path line should go straight and turning 90 degrees only when hitting a wall.

At the end, what we need is a system that, given a certain grid with certain obstacles inside, produces a map of all possible paths, but taking into account the 2 (A and B) constrains.

Is this something that A* Pathfinding Project can do?

Thank you.


This is not a constraint that can be formulated using the A* algorithm (or at least not easily). You’d need something else for this I’m afraid.

Thank you for having confirmed it, yes, we were thinking it couldn’t be done easily. We’ll need to make something custom then.


1 Like