- Home /
How to stop a randomly generated track (from prefabs with different angle turns) to stop intersecting itself?
I have prefabs with (roughly as done in 3dsmax) ,30,45,90 and 180 degree turns as well as straight road. I am currently instantiating them onto the end of the last bit of road using a couple of spheres at the ends of each bit of road as the guiding points to join (think like scalectrix or jigsaw pieces where the end pieces slot in so the rest of the shape is in the right position and rotation. The road is currently generated randomly although eventually it will be done heuristically according to a difficulty scale.
The road can have various configurations like two uturns after each other, or just a 90deg turn back toward the rest of the track that results in it intersecting with existing sections of track. How can I prevent this?
at first I thought just to destroy the track that is being intersected, but if the player hasn't passed through that section yet it will break the player's ability to drive the endless track. I know it is a problem kind of like creating a snake-style game AI, but I don't really have a grid or many variables to work with. The track is technically 3d, but its very flat to the point of appearing 2d, so raycasting etc might be more difficult.
Any ideas?
Your answer
Follow this Question
Related Questions
Algorithm used for pathfinding using NavMesh by unity? 1 Answer
Generate tiles along a path a certain distance before reaching end position 1 Answer
Using A* Algorithm for Pathfinding for a 2D platformer 1 Answer
astar' AI falls down, doesn't follow the grid 2 Answers
Make a flying enemy ? 0 Answers