Very often in development I find myself having to bring an object to my camera’s position, but there’s no built-in way to do this quite simple task, so I set out to solve it.
To use, first set a shortcut for it in the studio shortcuts menu. In the unlikely event this plugin updates in the future, you may need to rebind your shortcuts. This plugin’s shortcuts can be found by searching up “camera” in the search bar.
If you don’t know where to find the shortcuts menu, go to the top left of your studio window and go to File > Advanced > Customize Shortcuts...
There’s two shortcuts, one that brings selected objects to the camera and preserves the object’s rotation, and another that will pivot all selected objects to the camera’s cframe.
Plugin Source, if interested
--[[ Variables ]]--
-- Services --
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Players = game:GetService("Players")
local Selection = game:GetService("Selection");
local StudioService = game:GetService("StudioService");
-- Plugin --
local isDebugEnabled = false;
--[[ Functions ]]--
local oldPrint = print;
local function print(...)
if (isDebugEnabled) then
oldPrint(...);
end
end
function onSummon(preserveRotation)
local recording = ChangeHistoryService:TryBeginRecording("EllieCameraSummon");
if (not recording) then
warn("EllieCameraSummon: error while trying to begin recording!");
return;
end
local cam = workspace.CurrentCamera;
local camCF = cam.CFrame;
local camPosCF = CFrame.new(camCF.Position);
local total = 0;
for _, v in next, Selection:Get() do
if (not v:IsA("PVInstance") or v == workspace) then
continue;
end
if (preserveRotation) then
v:PivotTo(camPosCF * v:GetPivot().Rotation);
else
v:PivotTo(camCF);
end
total += 1;
end
print("Summoned " .. total .. " object(s) to the camera!");
print("Rotation preserved: " .. tostring(preserveRotation));
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit);
end
function checkUser()
local user = StudioService:GetUserId();
if (user == 150006422) then
isDebugEnabled = true;
end
end
function init()
local function onBasicSummonWrapper()
onSummon(true);
end
local function onAlternateSummonWrapper()
onSummon(false);
end
local basicSummonAction = plugin:CreatePluginAction("EllieBasicCameraSummonAction", "Summon to Camera", "Summons selected objects to the camera's position, preserving rotation", "rbxassetid://13085201731", true);
basicSummonAction.Triggered:Connect(onBasicSummonWrapper);
local altSummonAction = plugin:CreatePluginAction("EllieAlternateCameraSummonAction", "Alt. Summon to Camera", "Summons selected objects to the camera's CFrame, does *not* preserve rotation", "rbxassetid://13085201731", true);
altSummonAction.Triggered:Connect(onAlternateSummonWrapper);
checkUser();
print("CameraSummon initialized");
end
init();