0 votes

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.

Godot version 3.3.2
in Engine by (75 points)

1 Answer

0 votes
Best answer

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.

by (430 points)
selected by

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?

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.