- Home /
A* (AStar) Pathfinding Issue - Path not spawning instantly
Hi,
in my scene I am instantiating a couple of enemies very fast after another (the game has a enemy wave system). As long as I instantiate four enemies or less it works fine -> They spawn, the path to the player appears and they start to chase. As soon as I instantiate more than 4, the first 4 start to move directly on them path, but the rest is waiting like one second or two and then getting their path and start chasing also. In my case this is exactly what I want, because otherwise a bigger wave is impossible to handle BUT NOW I want to implement a pause menu (I did this with Time.timescale=0) and when I pause and then resume the game a couple of seconds later, all of the enemies have their path ready now and they all attack exactly at the same time. It looks like there is some kind of queue behind this: As soon as the queue (which can maximum contain 4 elements?!) is processed, the next 4 elements are being processed. Am I right or does this work completely different? If yes, where can I change the queue size or who do I manage to stop the process of assigning paths as soon as I press the pause button and continue the assignment where it stopped before when I press resume?
Best regards!
I assume youre using the A* Project by Aron Granberg? I just got the pro version a few days ago, so I don't know these ins and outs, but I think the delay is because you are only using one thread and it can only take 4 before there is a difference in performance and thus the project stops it to prevent FPS loss? $$anonymous$$aybe something to do with repath rates also?
I think the best thing to do if you want some async going, is to code it into your spawn script. You can manually calulcate a path and you really have full controll over that. If you take manual control of the path creation, there are something on this on the getting started pages of the documents, then you can cancel it or just avoid assigning it to the AI while the timescale is 0.
We need some more info here. You want to spawn your AIs and then wait a little bit before they get their paths? Why not spawn your AIs in $$anonymous$$iwaves of 4 etc with a very small delay? What implementation of A* are you using?
I recommend asking this directly in Granberg's own forum for the APP.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200609im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I go about making a 2d platform enemy ai 1 Answer
Astar Pathfinding ai moves more nodes than it should 0 Answers
Colliders and Astar 0 Answers
Sidescroller AI/Pathfinding/Flags/Waypoints 0 Answers
AI (Prolog) programming on Unity 1 Answer