Posts

Showing posts with the label path-finding

Multithread Pathfinding, Unit can't receive path array result

Image
Clash Royale CLAN TAG #URR8PPP Multithread Pathfinding, Unit can't receive path array result I have a pathfinder program using A* that i made following a tutorial. It works fine until i tried to make it multithread using async Task. The Thread works and the path is calculated, but when the path result is being passed to the Unit object, for some resaon only one or two Unit that receive the path array. where did i do wrong ? RequestManager : public class ThreadRequestManager : MonoBehaviour { Queue<PathResult> results = new Queue<PathResult>(); static ThreadRequestManager instance; ThreadPathfinding pathfinding; private void Awake() { instance = this; pathfinding = GetComponent<ThreadPathfinding>(); } private void Update() { if (results.Count > 0) { int itemsInQueue = results.Count; lock (results) { for(int i = 0; i < itemsInQueue; i++) { PathResult result = results.Dequeue(); ...