Camera Plugin | Record your studio's camera's movement and play it back in game

Ever tried to make a smooth camera tween that just becomes too complicated? Well, this plugin is for you! It’s made to record you camera’s movement, and give you the ability to play it back.

image

How It Works

When you click the icon, it immediately starts recording your studio’s camera’s position, so start moving!
It’ll create multiple ModuleScripts, due to plugins limited to setting a maximum of around 200,000 characters for each script. Each Data Module returns a list of CFrames, which then the main module sews them together, and plays them back


Example of the source of one of the Data Modules

Get Started

Install the plugin, you’ll see a new icon popup
The icon’s still being moderated, so please be patient
image
Click it, and there should be a gray background to it,
image
Start moving, the script’s recording your camera at 60 FPS!
Once your done moving around your builds, Look in game.ReplicatedStorage, there should be a new ModuleScript there, named CameraAnimation.

Playing It Back

I expect you to read Get Started, before you read this.
To play it back, simply run this in the studio’s command bar, or in a localscript. If you moved the ModuleScript, change the path in this sniplet

game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable;
require(game.ReplicatedStorage.CameraAnimation).Start();
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom;
Source Code
if not plugin then return end
local toolbar = plugin:CreateToolbar("Camera Tools")
local newScriptButton = toolbar:CreateButton("Record Camera", "Record the camera's position and create a smooth \"tween\" for it", "rbxassetid://6547323021")
local recording = false
local function roundAllNumbersInList(l)
	local finished = {}
	
	for i,v in pairs(l) do
		if type(v) == "number" then
			v = string.format("%0.5f", v) -- save space
		end
		table.insert(finished,v)
	end
	
	return finished
end

newScriptButton.Click:Connect(function()
	recording = not recording
	if recording then
		print("Recording...")
		local Heartbeat = game:GetService("RunService").Heartbeat
		local mainsrc = [[
local Heartbeat = game:GetService("RunService").Heartbeat
local TweenService = game:GetService("TweenService")
local module = {}
module.setCameraPosition = function(cf)
	TweenService:Create(game.Workspace.CurrentCamera,TweenInfo.new(1/60,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{CFrame=cf}):Play()
end
module.Start = function()
	local s = module.setCameraPosition
	local d = function() Heartbeat:Wait() end
	local DataSrcsAmount = {{DataSrcsAmount}}
	for i=1,DataSrcsAmount do
		local Data = require(script["Data"..i])
		for i2,v2 in pairs(Data) do
			s(v2)
			d()
		end
	end
end
return module
		]]
		local startersrc = "local n = CFrame.new\nreturn{"
		local srcs = {startersrc}
		local currentSrc = 1
		while Heartbeat:Wait() and recording do 	
			local add = "\n\tn("..table.concat(roundAllNumbersInList({game.Workspace.CurrentCamera.CFrame:GetComponents()}),",").."),"
			srcs[currentSrc]..=add
			if string.len(srcs[currentSrc]) > 145000 then
				srcs[currentSrc]..="\n}"
				currentSrc = currentSrc + 1
				srcs[currentSrc] = startersrc
			end
		end
		srcs[currentSrc]..="\n}"
		print("Finished recording, generating ModuleScript(s)")
		local ModuleScript = Instance.new("ModuleScript",game.ReplicatedStorage)
		ModuleScript.Name = "CameraAnimation"
		ModuleScript.Source = mainsrc:gsub("{{DataSrcsAmount}}",currentSrc)
		
		for i,v in pairs(srcs) do
			local DataModuleScript = Instance.new("ModuleScript",ModuleScript)
			DataModuleScript.Name = "Data"..i
			DataModuleScript.Source = v
		end
		game:GetService("Selection"):Set({ModuleScript})
		print("Saved successfully")
	end
end)

If you have any questions, dm me at WhutThe#4005, or leave a comment!
Plugin:

16 Likes

Could you provide examples of how it works, preferably gifs so users can see what they are reading about?

1 Like

Its pretty self explanatory, You move your camera in studio, and it plays the movement back

Thanks for this, might use later. Seems like a good plugin too :smiley:

1 Like