Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Mirroring a CFrame? [Deprecated]

How would I go about mirroring a CFrame? I tried multiplying the Rotation vectors by math.rad(180) - individually by code, and simultaneously.

It was close but still obviously inaccurate. The part is merely rotated on the Y axis, and the mirror part was slightly etched on all three axis. It was close, though.

Does CFrame:inverse() do this? If not, is there a method/equation that does?

Thanks for reading.

Edit: I didn't want to mirror the CFrame, I wanted to mimic the rotation from a second person perspective - 180 degrees flip.

2 answers

Here's what I understand:

CFrame: 1,1,1 What you want: -1,-1,-1 Right?

If so, All you need to do is Multiply the current CFrame by -1 (-1*1 = -1)

2 comments

0

I figured it out on my own. I know how to use CFrame multiplication - all I had to do was reinstate the rotation.

0

Alright, but that's the method I would do if you were to swap the Vector3 from positive to negative.

This question has been asked

This function mirrors a CFrame about one of the origin's planes:

function mirrorCFrame(cf)
    local mi = Vector3.new(-1,1,1);
    local np = cf.p * mi;
    local mi = CFrame.new( np , np + cf.lookVector * mi * -1 );
    local up = CFrame.new(cf.p,cf.p + cf.lookVector);
    local from = up:toObjectSpace(cf);
    return mi:toWorldSpace(from) * CFrame.Angles(0,math.pi,0);
end

This discussion is preserved as it was. New answers, comments, and votes are closed.