As a developer, it is not easy to dynamically swap out welded components on a model. WeldConstraints are close, but don’t suit all of my needs because they don’t support attachments.
Attachments on turret slots for planes and on the mounting points of turrets for similar reasons
Attachment points of windows/window frame on pieces of a wall tileset so users can swap out windows in their walls
Attachment points on a farm plot model and on crops so they can be dynamically added to the plot
Benefits of Resolution:
If ROBLOX is able to address this issue, it will be a lot easier for me to switch out swappable components on models. My current options are to use attachments or a settings ModuleScript to store offset, and then connect with a standard weld.
As you can see, it's a lot easier to swap out turrets because I don't have to rebuild the weld each time, and I don't need to manually set the offsets of the constraint because attachments already do that. I'm not sure if it's more appropriate to incorporate this into WeldConstraint or make it its own class.
This is an interesting proposal. We have the WeldConstraint which constraint two parts in their initial relative locations. This is much simpler than adding another layer of cframes (aka Attachments).
Yep, I was originally looking at WeldConstraint to see if it offered this functionality. Unfortunately, these aren’t two parts I’m looking to weld based on their existing positions – I need a constraint to weld two attachments which could be anywhere in the world together.
Like you said though, using relative location instead of attachments is easier to use, so that’s why I mentioned I wasn’t sure if it was appropriate to integrate this into WeldConstraints (e.g. JoinBehavior = Part or Attachment w/ Part0/Part1 or Attachment0/Attachment1) or create a whole new class.
Yes you are right you’ll need a little script to do that. What you can do is place the two parts at the world positions of the attachments, and the use WeldConstraint. In pseudo code:
part0.CFrame = part0.CFrame * part0.Attachment.CFrame
part1.CFrame = part1.CFrame * part1.Attachment.CFrame
create WeldConstraint between part0 and part1
I wonder if you need a simulated “Rigid Constraint” that will enforce the relative locations of its Attachments using the physics solver. You could try this out by using a Hinge set up as a servo motor, which essentially behaves like a rigid constraint. It will move the parts for you based on the Attachment locations.
Agreed with @timobius. Attachment based Welds have a fundamental problems:
very easy to create an invalid configuration
the parts need to move into position that respect the attachment welds, and the motion is not physically defined
What you need is to explicitly move your parts into position for welding, the way you want. Otherwise like it was suggested, you might need a simulated rigid joint (which we don’t have at this point but a prismatic with a servo can emulate that).