How to Reflect an Animation on a Specific Axis?

I want to reflect a keyframe sequence on a certain axis. I know there are numerous tools that can achieve this such as Moon Animator, but they all flip on the same axis. For example, instead of flipping from left to right, I want to flip the forward axis to back, if that makes sense.

I understand that I could just rotate the animation any direction (180 degrees on the Y axis for my case) to get the desired pose I want, but since I have many animations, it will be difficult.

Is there a way I can modify this module from an animation mirroring plugin to flip along a different axis?

local module = {}


-- Table containing the paired names of the body parts, NOT the names of the joints
module.AlternateParts = {
	LeftUpperArm = "RightUpperArm",
	LeftLowerArm = "RightLowerArm",
	LeftHand = "RightHand",
	LeftUpperLeg = "RightUpperLeg",
	LeftLowerLeg = "RightLowerLeg",
	LeftFoot = "RightFoot",
	
	RightUpperArm = "LeftUpperArm",
	RightLowerArm = "LeftLowerArm",
	RightHand = "LeftHand",
	RightUpperLeg = "LeftUpperLeg",
	RightLowerLeg = "LeftLowerLeg",
	RightFoot = "LeftFoot",
	
	["Right Arm"] = "Left Arm",
	["Left Arm"] = "Right Arm",
	["Right Leg"] = "Left Leg",
	["Left Leg"] = "Right Leg"
}

-- Private
function module.MirrorPoseCFrame(cf)
	local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = cf:components()
	x = -x
	-- R00, R10, R20 (x)
	R10 = -R10
	R20 = -R20
	-- R01, R11, R21 (y) 
	R01 = -R01
	-- R02, R12, R22 (z) 
	R02 = -R02

	return CFrame.new(x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22)
end





return module

Code forked from this plugin.

I’m not entirely sure as I’ve never worked with CFrame components directly. But I believe removing either R10 = -R10 or R20 = -R20 will mirror backwards instead? It’s some combination of adding or removing from those set of components at the bottom. I’m sure there’s a way to know for certain, but I’m too tired to figure that out right now.

Here’s a guide I was reading:

1 Like

Thanks for your response; I’ve been trying to tamper with those bottom components but to no avail. I could spend another hour trying more combinations, but there’s just too many to try. Hopefully a CFrame wizard stops by to help out.

1 Like