CFrame+Tween doors working with physical model

Hello everyone.
I am currently in the process of creating a door using PrismaticConstraint to check various behaviors, and have found that apparently if the Speed is too slow, the part will sleep and not work properly.

So I am trying to give up on doors that work with physics and try a different approach.
I know that the principle of tween models is that they are anchored, but let’s say that there is a part B (welded to A) that is a child of a part A that works with physics.
Part B basically moves according to A’s physics, but can it be moved in CFrame based on A’s coordinates?

Sorry for the difficult to read writing style.
Any input would be appreciated!

I think you’re looking to use welds( not the constraint version) because they allow a part to shift its position relative to another part while working with physics.

Thanks for the advice.

local PrimaryPart = script.Parent.PrimaryPart
local Parts = script.Parent:GetChildren()


for i = 1, #Parts do
	if Parts[i]:IsA('BasePart') then
		local weld = Instance.new("Weld")
		weld.Part0 = PrimaryPart
		weld.Part1 = Parts[i]
		weld.C0 = PrimaryPart.CFrame:inverse()
		weld.C1 = Parts[i].CFrame:inverse()
		weld.Parent = PrimaryPart
	end
end

I have tried this on a test model using a welding script like this one, and it seems that if the foundation is left free without anchor, when the door moves, the foundation is dragged along with it.
Perhaps others using other CFrame doors have temporarily removed the weld to allow the door to move.
(However, I do not like this technique as it could cause the door to come off the body during operation.)

Anyway, thanks for the help!

I’m not sure you’re getting what I meant, you aren’t supposed to directly change the part’s cframe but rather use the weld’s c0 and c1 properties to offset the parts.


example

1 Like
local door = script.Parent.Door
local base = script.Parent.Base

DoorWeld = Instance.new("Weld")
DoorWeld.Parent = base
DoorWeld.Part0 = base
DoorWeld.Part1 = door

DoorWeld.C1 = CFrame.new(1,0,0)

I have been doing a lot of research and trying, but have succeeded in getting the parts to work for now.
However, there is room for improvement, such as parts being welded in odd positions, so I’ll keep working on that!

local door = script.Parent.Door
local base = script.Parent.Base

DoorWeld = Instance.new("Weld")
DoorWeld.Parent = base
DoorWeld.Part0 = base
DoorWeld.Part1 = door
wait(3)
local TweenService = game : GetService ( "TweenService" )
local tweenInfo = TweenInfo.new(5)
local goal = {C0 = DoorWeld.C0 * CFrame.new(10,0,0)}
local twe = TweenService:Create(DoorWeld,tweenInfo,goal)
twe:Play()

When I played it back, it welded in a position I didn’t intend, but generally did what I wanted it to do!
Thank you!

To get it in the correct position maybe use a weld script or plugin to properly align the c1 and c0 but you’ll have to store the initial c1 or c0 in a variable (after applying the script or using the plugin) then multiply the offset by the variable .

newweld.C0 = part1.CFrame:inverse() * part2.CFrame

This solved the problem!