Trying to connect 2 attachments together

  1. What do you want to achieve?
    I’m trying to connect to position 2 models to connect together

  2. What is the issue?
    i need to connect the 2 model relative to the attachment but I can’t find the right way to do this

  3. What solutions have you tried so far?
    i tried to find solution on google, the devforum or even the developer hub, but i can’t find any solution to this problem, i tried many different calculation but can’t find the right one

EDIT: i found a gif that clarify what i’m trying to do

5 Likes

Hello, can you please tell us about what you’re trying to program, so we can help you further. It’s really important to make sure that we’re on the same track to give you sufficient help. Thank you.

1 Like

I’m currently trying to make a procedural dungeon generation. with some piece of dungeon that i would attach together to make a dungeon.

1 Like

Did you try other ways to make it? Because each problem has multiple solutions. Because I am not sure if that is possible.

EDIT: Added the last sentence, to clarify.

1 Like

Do you mean having a block connecting the two? You can use the gapfill plugin.

Or if you mean to script it, this might work

local thickness = -- Thickness
local Length = -- Length
local Attachment1 = -- Position of
local Attachment2 = --Position of
local magnitude = (Attachment1 - Attachment2).Magnitude

local Part = Instance.new("Part")
Part.Size = Vector3.new(magnitude, thickness, Length)
Part.Position = Attachment1 + Vector3.new(magnitude/2)
Part.Parent = workspace

if you have any questions just ask.

2 Likes

i’m trying to position each model in order to get the 2 attachments to have the same WorldPosition. This GIF explain pretty well what i’m trying to do:

1 Like

ahh, I see. So there is one thing you can do. Instead of an attachment you can use a part and set that as the primary part, and then simply set the primary part’s position to the other primary parts position.

1 Like

i already made that in the past, but i’m trying using attachment this time so i could make the “attachment” between room much more simple to do. but after that you point that out, i might get a solution using both attachment and primary part

1 Like

Yes, you can do that, but make sure the primary part is the part that moves

Edit: wait, I think you can use a constraint let me check

Edit I think you can use a vector force connecting the two with a massive force

1 Like

I agree with @VegetationBush’s solution, it’s easier to make, and it will work. I’ve used that with my colleague, when we were working on train scripts.

1 Like

I found the solution !
We have 2 piece, 1 that is the base and 1 that is the piece we want to attach.
The way i did it is pretty simple. Create a part that have for CFrame the attachment to the piece we try to attach. Set it as PrimaryPart and Set the PrimaryPart CFrame to the CFrame of the attachment of the base piece.
Thanks to @Fliper05YT and @VegetationBush for helping :slight_smile:

Result: https://www.youtube.com/watch?v=Nheg65AZnsQ&feature=youtu.be

5 Likes

Hmmm , i’m trying to do the same thing but idk if i’m dumb i don’t really understand the explanation;-;

1 Like

lol my bad i find a way but i have another question if someone can help about the problem of overlapsing room

1 Like

:rofl:This is the best solution, I have tried many attempt but this is the best XD, ;-; i didn’t think about the primarypart before LOL XD, Thank you for sharing this helpful thing.

1 Like

I don’t understand the explanation :frowning: could you please send a video demonstration or something. I also can’t open the video link

1 Like