How to pathfind without using tilemap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By HorseGorilla

Hello!

Like the Binding of Isaac, I created a room out of sprites to place obstacles and enemies. (using arrays)

The Binding of Isaac used arrays, which I don’t know for now, and numbered them lower and farther away from the player’s position.

As a result, enemies dodge a number of obstacles and move to the location closest to the player. However, it is very inefficient to give each enemy such an arrangement and calculate the path for every delta.

Do you know Navigation2D dynamically allocating obstacles and avoiding them?
or Is there a way to avoid using A-Star?

It’s hard to get a clear idea with all of them using Tilemap.

Thanks for the poor English too.

:bust_in_silhouette: Reply From: vnmk8

a way to use Navigation2D without tilemaps is with the NavigationPolygonInstance node, is a polygon shape and inside you place the coordinates of the obstacles.

Thank you for answer!

If I use polygons to individually collide with obstacles in the editor and then instance them, will the navigation point to the player avoiding the obstacles?

HorseGorilla | 2021-08-01 00:00

with the NavigationPolygonInstance node you create a polygon shape and holes in it the holes become the obstacles, to place instances as obstacles for pathfinding i would place the obstacles before the scene loads inside the holes, but to change the obstacles at runtime dynamically haven’t done that, i leave example images of the NavigationPolygonInstance nodes:
scene
scene

vnmk8 | 2021-08-01 00:26

Thank you, I will make big rectangle (room, in editor)and subtract collision shape of obstacle in runtime.

HorseGorilla | 2021-08-01 06:18

Hows the performance? Can you tell me

Kushal | 2022-04-11 16:31

Unfortunately, I use astar2d now in my project. sorry for you that I can’t inform.

HorseGorilla | 2022-04-12 13:41

No problem man

Kushal | 2022-04-13 23:19