What do you want to achieve? Mirror the Viewport dummy in a mirror-like style.
What is the issue? It looks like if you were looking at someone, instead of looking at a mirror. I essentially want to invert the Viewport dummy’s rotation.
What solutions have you tried so far? I have tried adding an offset value, with Vector3 using -math.pi on the Y axis, then multiplying the value with the character’s HRP value. I also looked around on the Dev Forum.
Currently, I have it set up to clone the dummy to the player’s CFrame.
RS.Stepped:Connect(function()
local currentCharacter = plr.Character
if currentCharacter and currentCharacter:FindFirstChild("HumanoidRootPart") and dummy:FindFirstChild("HumanoidRootPart") then
dummy.HumanoidRootPart.CFrame = currentCharacter.HumanoidRootPart.CFrame
end
end)
Is there a math formula I could use to achieve this effect, or is there another way?
Reverse the size of the Viewport frame. This effectively swaps the position of everything. You may need to fix the position, but other than that it should work.
You don’t need any formulas, just think about how the rotation of the reflection compares to the rotation of the player.
local currentCF = currentCharacter.HumanoidRootPart.CFrame
local x, y, z = currentCF:ToEulerAnglesXYZ()
dummy.HumanoidRootPart.CFrame = CFrame.new(currentCF.Position) * CFrame.Angles(x, -y, -z)
If you don’t want to update the position of the dummy and want to only mirror the rotation then you can remove the CFrame.new(currentCF.Position) part.
While this works rotation wise, it does not accurately mirror the character when they move. What I ended up doing was keeping the code I had, but I then rotated the dummy’s HumanoidRootPart upside down and backwards. In addition, I turned the ViewportFrame upside down. Here is the final result: