How would I go about preventing overlapping models in pipe generation?

I’m making a pipe generation script that will generate a group of pipes on command. The pipes spawn connecting to another at pre determined connection points.

The problem is that I have not figured out how to avoid the generating pipes from overlapping one another. Pipes will spawn right over another pipe multiple times.

I tried adding a function to check if a new pipe will overlap an old one, however this only halted the generation. I believe the way to go about it is somehow checking a step or two ahead to see if the next few generated pipes will overlap another.

What are some possible solutions to the issue that I could use? Some sort of algorithm or method I could look into?

2 Likes

I am not a scripter but u union them to stop them or move them 0.001 studs up or down and right or left.

Thats building related, this is a scripting issue.

And honestly, haven’t figured this out myself. Only thing I can think of is to assign some kind of “grid” to pipes, where its like a position relative to the first pipe. So the first ever pipe is 0, 0, 0, then if it goes up or left or wherever, change its “grid position”. Then when generating, check if that grid is already taken.

That is an idea. I will try incorporating a grid to the pipes and see where I get from there.

May be years late, but I do wonder if you found a solution to the problem.

Yes, I do know how to prevent it now. Reference your existing generation in a table and check if a part/model exists for every new part/model.

Ironically, I am having the same problem with pipes that are player sized now except it’s more with overlapping so I’m still confused.

I know I solved this issue before. If I can find my old code, I’ll provide you with a more in depth solution.

Thank you for helping me to solve my issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.