Topic was automatically imported from the old Question2Answer platform.
Asked By
Desertdweller
Old Version
Published before Godot 3 was released.
I have been working on a small project with enemies who will be able to pathfind around objects, and etc. I plan to have multiple enemies on the screen at one time, so I have the enemy scene instanced. The problem I am running into, is the fact that I cannot (as far as I am aware), use the Navigation2D node outside of the enemy scene. However, I cannot place the NavigationPolygonInstance in the enemy scene, because I would not be able to create it inside of my game world. This of course conflicts with the need for the NavigationPolygonInstance to be a child of the Navigation2D.
Why can’t you have your Navigation/Polygon as a part of the world your enemies are pathfinding around? I’m not even sure how it would work to have the navigation on the enemies…
All you need is to have some function on your enemy that references their world (assume the enemy is a direct child of the world), and returns the path from their position to wherever they’re aiming for.