Explain ToObjectSpace

Please explain and elaborate the best way possible to help me understand ToObjectSpace, explain it to me as if im 5

Please search before posting, i.e. What does ToObjectSpace() and ToWorldSpace() do?

i literally just read that but i really do not understand it


like does this mean it is treating objectA as the centre of the world?

No it is treating objectB’s CFrame as the center of the world.

and why is it printing +10 when object a is UNDER object b

shouldnt it print (0,-10,0) instead

it treats object a as the center, what it returns is the cframe you’ll have to multiply object a with to get back to object b
here’s an example

print(CFrame.new(0, 10, 0):ToObjectSpace(CFrame.new(0, 12, 0)))

it prints

0, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1

it’s the equivalent of doing a:Inverse() * b

1 Like

its treating object a as centre?

Yes. Object A is treated as the center, the resultant cframe is the offset of Object B from Object A

I’m really confused because @sjr04 replied above and said object b is treated as Centre and now you’re saying object a is treated as Centre .

Ahhh I don’t know who’s correct

It’s treating object A as the center, you can see that the output of the code proves so

1 Like