No matter how I seem to go about it, setting the camera position seems to be impossible with plugin development. I also cannot post in a good portion of the boards, so if this belongs somewhere else, I can’t post there, so I don’t know what you want me to do about that.
I’m making a viewmodel animation plugin for my CFrame based animations, and as you can see, you can’t clearly see all of the arc handles to rotate the arm, so I need to be able to get out of the set “Camera position”, make changes, and then reset the camera to the proper location so I can visualize how it will look when in use. The problem is, my camera reset function seems to work about 10% of the time and other times it will look off into nowhere. And when it does set itself properly, if i move even a fraction of an inch using default studio tools, I shoot off to where I was before. I assume this is because studio stores information about the camera’s coordinateframe somewhere outside of the camera object?
Anyways, here’s my code and a screenshot of the plugin so far. Any assistance is appreciated.
local toolbar = plugin:CreateToolbar("Redux Animator")
local loadRigButton = toolbar:CreateButton("LoadRig", "Create an arm-set", "rbxassetid://3394625851")
local resetCameraButton = toolbar:CreateButton("ResetCamera", "Re-position the camera in the rig.", "rbxassetid://3397520948")
local PluginOpen = false
local DefaultRightArmCF = CFrame.new(.55,-.8,0) * CFrame.Angles(math.rad(90),0,0)
local DefaultLeftArmCF = CFrame.new() * CFrame.Angles(math.rad(-20),0,math.rad(10))
local ActiveWeapon = nil
local RightArm = nil
local LeftArm = nil
local CorePosition = nil
local CameraPosition = nil
local function LoadRig()
if not PluginOpen then
PluginOpen = true
ActiveWeapon = game.ReplicatedStorage.ActiveWeapon:Clone()
ActiveWeapon.PrimaryPart = ActiveWeapon.RightHandle
ActiveWeapon.Parent = game.Workspace
RightArm = game.ReplicatedStorage.RightArm:Clone()
RightArm.Parent = game.Workspace
LeftArm = game.ReplicatedStorage.LeftArm:Clone()
LeftArm.Parent = game.Workspace
CorePosition = game.Workspace.CurrentCamera.CFrame * CFrame.new(0,0,-.5)
CameraPosition = game.Workspace.CurrentCamera.CFrame
RightArm:SetPrimaryPartCFrame(CorePosition * DefaultRightArmCF)
ActiveWeapon:SetPrimaryPartCFrame(RightArm.Hand.CFrame)
LeftArm:SetPrimaryPartCFrame(ActiveWeapon.LeftHandle.CFrame * DefaultLeftArmCF)
local RightArmRotate = Instance.new("ArcHandles", game:GetService("CoreGui"))
RightArmRotate.Adornee = RightArm.PrimePart
else
PluginOpen = false
RightArm:Destroy()
LeftArm:Destroy()
ActiveWeapon:Destroy()
ActiveWeapon = nil
RightArm = nil
LeftArm = nil
game:GetService("CoreGui"):ClearAllChildren()
end
end
local function ResetCamera()
game.Workspace.CurrentCamera.CFrame = CameraPosition
end
loadRigButton.Click:Connect(LoadRig)
resetCameraButton.Click:Connect(ResetCamera)