Efficient path finding for multiple objects to find a path to another moving object

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

This is probably is a trivial question, but I still can’t figure it out. I am working on a game where there are several enemies that are trying to get to the player, who is constantly moving. I’ve only got it to move towards the player, disregarding any obstacles in the path, so the enemies sometimes get stuck.

I have tried using AStar and Navigation2D to calculate a path to find the player, but AStar wouldn’t even work, and Navigation2D ended up making the game too slow and unresponsive. I tried limiting the number of enemies alive, but there was no point where the game was difficult enough and running smoothly.

With that, my question is: is there a more efficient way to find a path from multiple instances to a moving object?

:bust_in_silhouette: Reply From: zircher

I’ll answer this generically, since I’m new to Godot. It sounds like you need something lightweight compared to Navigation2d. Can you set up an array of way points for the enemy AI to follow and create a couple of utility functions that can find the closest waypoint to the player and another that ‘walks’ the waypoints? Basically a lighter/coarser version of Nav2d. I know this technique was used in the early 3D engines like Unreal when they did not have as much computing power.