What's the best way to weld a lot of parts?

Hello, guys. I’m making vehicle building system. So, vehicles can be built within pad boundaries, and after, you can spawn it. But, vehicle should just break on spawn - so I need WELD parts together. Nearby parts, because there’s also motors, servos…
And after some scripting, I realized that I have 2 ways to weld parts:

  1. Weld every overlapping/touching part with other part. Even if that part already welded to current part with weld’s “chain”. Faster than 2 way.
  2. Weld every overlapping/touching part if there’s no weld “chains” to it. Slower, because I need check for every existing chain.

But, to decide what way I need use, I need know, will be there any PHYSICAL and PERFORMANCE diffirences for such weldings:
Way 1:
image
Way 2:
image
(Images above are visualise part’s welds if every part here are overlap)

1 Like

If you’re making use of WeldConstraints, allow me to introduce “Way 3” to you, choose one part to be your main part, like the chassis of your vehicle for instance, and whatever needs to be welded to that chassis, just create a WeldConstraint from the chassis part to that part you want to weld to it. Parts don’t need to touch to be welded together, and WeldConstraints won’t move the parts into the same position.

My system REQUIRES that 2 parts should touch eachother, because PLAYER can build his car, and if I’ll just weld smth by random, I’ll end up with wheels welded to chassis, and this will result in not working car.

In that case, why don’t you just make it so that (I assume that placing parts will happen with the mouse and clicking) when you click on a part to place a part on it, it automatically welds the part to the part you’ve clicked on.

Also, for the wheels, if you’d make a system that only welds the WeldPart (for instance) in the model of the wheel to the chassis, with the wheel being hinged onto that WeldPart, the wheels will work.

You can use this (but you need to think how this equation be 3d):

Or you can make ur own algorithm (ex: storage step by step welds)

1 Like

Because my system constucted like this:

  1. Player obtains and places vehicle pad.
  2. Player enters build mode
  3. Player builds his vehicle with empty SCHEMATICS, and Motors, Servos which he crafted/bought.
  4. Player fills all schematics in vehicle.
  5. Player is happy and driving around island
  6. Player crashed his car. ← Car here have a lot of broken welds, because schematics have their own Durability.
  7. Player wants to respawn car.
  8. I need to get vehicle’s data, build it, and then weld it. Saving welds will consume more data.

My main question was is there any diffirence in performance if I just weld all overlapping parts together, or it’s better to make weld chains?

In my opinion having more welds will result in more instances, which ultimately results in insane lag.
Let’s say you have a car with 9000 parts (just an example), and you add another part to it. The script will then literally create another 9000 welds.

Reducing the number of welds will of course improve performance if it doesn’t damage what you are doing.

Bare in mind though, even though option 2 is still better, in the same 9000 parts example, the script will go over 9000 parts and check for their children, so both options are definitely not optimal.