I am creating random paths of a specified length in a rectangle. The goal is a dynamic tower defense map. (ie, there is a path for the bad guys to follow, and space in between paths to put towers.) I have a mostly working Path generator. Generally speaking, a path is created without a major issue most of the time. Good looking path Example. There is 1 close spot there in the middle, but good enough. I have 2 big issues right now. 1) Two path sections get too close to each other in parallel, leaving too little room for towers between. This is usually a V shape. But also could be two curves in paths. #1 here is usually not bad enough to be game breaking. But sometimes it is game breaking bad. 2) The path crosses itself. This is actually very rare already. On the rare occasions when it happens #2 is almost always 100% game breaking. I am attempting to rewrite this section of my code to resolve both of these issues. Overview of current logic... Make path manually with only 1st and last 2 points At the location which I want to be the start and end of the path. Set constants defining limits of Box within which I want my path to stay. Randomly choose X and Y in box rounded to nearest 32. This was my attempt to ensure room between paths. I tried bigger numbers and it did not really help. Place X,Y in path at place with shortest length. This was my attempt to ensure no crosses. Made script to do this looping through each position in path. Check Length, continue until desired length. My current plan to fix the 1st big issue... 1st step; Ensure minimum distance. After choosing a random X and Y. Add a bunch of points in a copy of the path at intervals to get a high-res path. Thinking ~500 should be plenty? At ~6000 length paths right now, That would give me ~12 pixel accuracy; I think. Question? Assuming I am making a script for this... Am I better off creating an array? Or create a new path? Find closest point, which would be roughly equivalent to perpendicular to path. Get the distance. Ensure that point is distance > Tower width + Enemy width + Tolerance Tolerance being a number bigger than the error I think the distance is giving me. Insert point in original low-res path. 2nd step; Check for Acute Angle. After point inserted in shorted length position. Check the angle of the new point vs the 2 adjacent points on the path. If this angle is too small (degrees to be determined later), then I know the path is overlapping itself in a V shape. Then I would inject 2 points adjacent to the new point to create more of a U shape. Hopefully this fix allows the shortest path code to ensure no Crosses too? Will have to test to see. This seems very processor intensive. I have already had to split up creation once because nothing happened. It seemed like the code just ran out of time in 1 frame? Not sure what it was, but making the object do 1 portion at a time then alarm until next frame worked. Am I just far too concerned with efficiency / memory / processor time? Thus? Is there a function for this? Find the distance to the path from X,Y? Not a point on the path, but the perpendicular point along path itself? If not, other ideas are also welcome.