Zahir J
Zahir J

Reputation: 1179

Restrict Navigation2D to the 4 cardinal points

I have this procedurally generated maze which I solve using the Navigation2D. It looks like this

enter image description here

I have turned Show Navigation on in the Debug menu hence the green outline. As the sprite takes a corner you can see it's taking the slanted line.

I want it to restrict itself to right-angled turns only. I configured the navigation polygon to 4 pixels wide, and the inverse of that polygon as my collision polygon so it's supposed to be a tight fit?. I am confused as to why there's that blurry outline at the vertices.

My repo is here https://github.com/plasticruler/tower-defence-maze

Also, any comments on why it doesn't always return the shortest path?

Upvotes: 2

Views: 88

Answers (1)

Mef
Mef

Reputation: 36

I've done some research and even tried to code it myself but sadly no positive results. You could try solving the maze by sending some "agents" with restricted 4 directional movements and the agent with the shortest path is your answer something like an Ant simulation Video I recommend watching about Ant simulation. I also had found this useful video by GDquest that you might find helpfulVideo

Upvotes: 1

Related Questions