Hello I’m trying to understand C0 and C1 more. I was watching a tutorial about welding. The code below is supposed to put an object above your head when you touch it, and it will move around when you do. I understand basically all the code and why it’s their except the two lines about C0 and C1. I tried looking through the api but I don’t understand still and even here on the dev forum but most of the answers is basically just “without this the code won’t work” or a complicated answer I don’t understand. Can someone explain to me the C0 and C1 properties and why the inverse is there, like I’m an idiot. Thanks!
The weld article describes the behavior of welds as
If you want the parts to keep their offset from eachother, you want roblox to determine a cframe for part1 and part0 which satisfies the above equation
Say you have two positions, a and b which you want the weld to put the parts at
b * C1 == a * C0
One of the multiple ways to solve this equation is to solve it such that both sides are equal to 0,0,0 and the equation is satisfied
The way you do this is the opposite of cframe multiplication, inverse
b * b:Inverse() == 0,0,0 (in a similar way that 10/10 is 1, or 48/48 is 1)
a * a:Inverse() == 0,0,0
b * b:Inverse() == a * a:Inverse()
When you set the C1 and C0 to the inverses, all roblox sees is
p1 * b:Inverse() == p0 * a:Inverse()
Roblox then says what value of p1 and p0 would satisfy this equation?
It then chooses b and a, the desired cframe values because thats what satisfies the equation
We end up with our solution
b * b:Inverse() == a * a:Inverse()
However, I dont like this solution personally because its old, inaccurate, and makes very little sense
I like to solve the equation ignoring c1, so making it 0,0,0 or not messing with it, then solving the equation from there
p1 == p0 * c0
You then “divide” both sides by p0
p0:Inverse() * p1 == c0
Or
c0 == p0:Inverse() * p1
This is a way to derive CFrame:ToObjectSpace() and makes much more sense with the rest of roblox math and again doesnt have inaccuracies
I would recommend switching to this method, this isnt related to your question but just while youre at it
I hope this helps, if it doesnt make sense just send a message