- Home /
The question is answered, right answer was accepted
How do I detect intersections on roads that are made out of points?
So I'm working on a city building game again, and I have a few problems concerning roads. Road intersections. There is a method ive been looking up for making roads. I am making the straight roads out of two points, that then generates the geometry at the start and the end, and the cars lerp between the start and end points. For curved roads, the roads are part of an arc of the circle. Using basic geometry, I have found the length of the arc that is the road, and then divided the road by a number of segments equal to its length. This gives a pretty accurate, clean edged curve. Since the straight roads are made up of two nodes, and the curved roads are made up of multiple nodes, how do I create intersections? At the minute, I know how to draw roads, so long as none of them touch each other. But how would I go about snapping the roads to existing roads, or making intersections? I could make it snap to an existing roads node if it is within a certain radius of it, but then it wouldn't snap to straight roads (only a node at the start and end) and would snap to every metre along curved roads rather than anywhere on the road. Sorry that's not very well explained, but I'm not sure how I could go about this. Thanks for any help you can give me.
Answer by joshua-lyness · Jul 13, 2016 at 05:32 PM
This isn't relevant anymore. But for anyone trying something similar, just compare distances between the two road's points, and if they get close enough to each other, create more points around it by lerping the two Vector3's, and continue until it is close enough they most likely intersect. Theres no definite way of doing this. :)
Follow this Question
Related Questions
detect if two objects in a list intersect in editor. 0 Answers
Snap point to point on another prefab 1 Answer
Unreal Tournament like points/nodes 1 Answer
2D simple road system with curves and intersections 0 Answers
What's the best/easiest way to do something like Bounds.Intersects but accounting for rotation? 1 Answer