Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to determine the lowest distance to an end location that is a feasible direction?

Asked by 5 years ago

Hey guys! I've been working on a controlling/attacking game. Essentially, if I select one area to go to another area, the way that the troops are decided to go there is by calculating the lowest distance of bordering lands and taking the one of the lowest distance. This works in a single land mass, however, if I connect one land mass with a second land mass, by a bridge they can cross, this does not work, because the troops will instead move to the edge of the land mass if that's the shortest distance and then break since they cannot go anywhere of a lower distance that will get them closer to the end location. I'm a little unsure of where to go from here and have been brainstorming the past few days. See, I don't necessarily want to try a brute force method in determining where to go, since in larger maps this would cause lag with multiple movements going on at once. Not looking for code, just different perspectives or different ways I could achieve this. The way I determine surrounding lands is by using a function GetTouchs(Input) where Input is cloned, the clone is slightly bigger by 0.1 on the X and Z sizes, and an array of items touching it minus what it was cloned from is returned. Any ideas? I figured I might ask since I haven't come up with a solution in three days filled with testing and more attempts. Maybe someone has a simple solution I overlooked. Thanks!

0
I haven't started fiddling around with this yet but possibly using pathfinding? The pathfinding service I have used a tiny bit but it has worked well. xEmmalyx 285 — 5y

Answer this question