I have a Motor6D that controls a part, and I need to alter its Transform so that the part1 moves to a CFrame in the world. Here is a diagram of what I want to do:
Hello, solving this issue is actually pretty simple:
Motor6D.C0
is equivalent to the CFrame
transformation from Part0
’s (in this case Parent’s) CFrame
: Part1.CFrame = Part0.CFrame*Motor6D.C0
. This means that you need set C0
to the CFrame
value required to transform Part0
’s CFrame
to the target CFrame
. Let’s try to imagine this in an equation:
Let P = Part0.CFrame
, T = targetCFrame
, C0 = Motor6D.C0
:
We are trying to solve: P * C0 = T
.
Since CFrame
values are matrices, we can solve this equation by simply multiplying by the inverse of P
(P:Inverse() or P^-1
).
This gives us: C0 = P^-1 * T
, which is our answer. In code, this would look like:
Motor6D.C0 = Part0.CFrame:Inverse()*targetCFrame
Here’s also a re-drawing of your image to demonstrate this:
Hope this helps!
1 Like