Just looking for a simple explanation. I understand what inversing does and I understand how CFrame work. I just never understood why I did some things that I do (for example inversing after welding). Any help would be appreciated.
Inverse()
is like the negative version of a CFrame.
So you can use it to compute offsets:
local a = PartA.CFrame
local b = PartB.CFrame
local aToB = b:Inverse() * a -- b:ToObjectSpace(a) does this same thing
So in this example,
a * aToB == b
This is useful for welds because welds only know about offsets.
So if you were welding PartA
to PartB
you would just need to set the C0
of the weld to aToB
, because C0
literally means “the offset from Part0 to Part1” (if C1
is CFrame.new()
).
local w = Instance.new("Weld")
w.Part0 = PartA
w.Part1 = PartB
w.C0 = aToB -- b:Inverse() * a or b:ToObjectSpace(a)
2 Likes