As the warning says, instead of using the deprecated Navigation
node (which will be removed in future versions of Godot), you should instead use the NavigationServer
object directly (from code), along with its associated methods, including map_get_path()
.
So, something like this:
var path = NavigationServer.map_get_path(...)
See the docs here.