) tutorial series on A* pathfinding, and I found that it works almost perfectly if there is one target that is used for calculating of paths. I don’t understand what am I supposed to do to make the algorithm effectively calculate more than one path as in to calculate path for each unit if each unit has separate target. I would appreciate if someone could at least explain to me why the algorithm freaks out if i try to use more than one target when doing calculations at the same time.
Also just to add since AStar algorithm does not change anything but returns list of nodes that make a path you can possibly run it each in separate thread if you wish.
Well if I understand this correctly PathRequestManager.RequestPath(transform.position, target.position, OnPathFound); is what does the calculation of the path
but than, I have two units each has its own target so I did this
Ok. I see, if there are 2 path request calls the first one gets overridden by the second one so both units go to second target. Both units have separate targets but this still causes the issue to occur.
You can see in the video that that its public static void RequestPath and I have more more than one call for PathRequestManager.RequestPath. Was the function supposed to be non static? If its not static I get an error saying ‘an object reference is required to access a non-static member’ which i don’t know how to fix.
… again… you don’t need to do anything with the scripts provided in the vid to make each thing go to it’s target, you only need to set the target in the unit script…
ok, i see what the problem was. I have one more issue, and that is that the script that does all the work needs to be unchecked in inspector for it to work without visible problems. If its checked the unit will ‘jerk’ rotate in place and stick around each waypoint and not continuously move from one waypoint to another like it does if the script is unchecked