I’m making building game. But I have a problem - I can’t correctly multiply two CFrames.
One example from my code: I have Block with Orientation: 0, 180, 90. I need change This Block Orientation to 0, 0, 0. I make this:
But instead of getting Block orientation 0, 0, 0 I receive Orientation 0, 0, 180. I receive this problem with 7 other orientations, but another 16 Orientations work perfectly. (I have all Blocks are rotated only 90 degrees → 0, 90, 180, -180, -90.)
Can someone tell me what I’m making wrong?
Sorry if I make any mistakes, I’m not good in English.
No. After printing (-math.rad(Block.Orientation.X), -math.rad(Block.Orientation.Y), -math.rad(Block.Orientation.Z)) it will print 0, -180, -90. But errors not exsist.
Idk, but why (0, 180, 90) + (0, -180, -90) = (0, 0, 180)?
local part = workspace.Part
part.CFrame = part.CFrame * (part.CFrame - part.CFrame.p):Inverse()
This will always reset the rotation to 0, 0, 0
If you want to make it more customizable, then you can use this:
local part = workspace.Part
local x, y, z = part.CFrame:ToOrientation()
part.CFrame = part.CFrame * CFrame.fromOrientation(x, 0, z):Inverse() -- Keep it flat on the ground but can rotate left to right