Hi, I was wondering how I can get the classic roblox camera script into my game. A video I took from a 2008 client:
I’ve searched on the internet and on the DevForum, but I couldn’t find anything. I know it’s possible because I’ve seen other games do it. Any help would be appreciated.
1 Like
I think you would just need to write your own classic Roblox camera script. I believe games with the classic camera did that too.
Under the CameraModule script inside of the PlayerModule, there are 2 scripts named ClassicCamera and LegacyCamera. One of these is probably what I’m looking for, but I don’t know how to get them out of ModuleScript form.
Where is this in Studio? e.g where is it under.
PlayerModule appears in StarterPlayerScripts when you run or play your game, along with a few other scripts.
So just this?
It is legacy, classic camera is something different. ( I don’t know if this would actually work as there is probably a reason why its a module) If you are looking to actually run the thing, find the thing that says require(game.StarterPack.StarterPlayerScripts.RbxCharacterSounds.PlayerModule.CameraModule.[replace with legacy])
local ZERO_VECTOR2 = Vector2.new()
local PITCH_LIMIT = math.rad(80)
local Util = require(script.Parent:WaitForChild("CameraUtils"))
local CameraInput = require(script.Parent:WaitForChild("CameraInput"))
--[[ Services ]]--
local PlayersService = game:GetService('Players')
--[[ The Module ]]--
local BaseCamera = require(script.Parent:WaitForChild("BaseCamera"))
local LegacyCamera = setmetatable({}, BaseCamera)
LegacyCamera.__index = LegacyCamera
function LegacyCamera.new()
local self = setmetatable(BaseCamera.new(), LegacyCamera)
self.cameraType = Enum.CameraType.Fixed
self.lastUpdate = tick()
self.lastDistanceToSubject = nil
return self
end
function LegacyCamera:GetModuleName()
return "LegacyCamera"
end
--[[ Functions overridden from BaseCamera ]]--
function LegacyCamera:SetCameraToSubjectDistance(desiredSubjectDistance)
return BaseCamera.SetCameraToSubjectDistance(self,desiredSubjectDistance)
end
function LegacyCamera:Update(dt: number): (CFrame, CFrame)
-- Cannot update until cameraType has been set
if not self.cameraType then return end
local now = tick()
local timeDelta = (now - self.lastUpdate)
local camera = workspace.CurrentCamera
local newCameraCFrame = camera.CFrame
local newCameraFocus = camera.Focus
local player = PlayersService.LocalPlayer
if self.lastUpdate == nil or timeDelta > 1 then
self.lastDistanceToSubject = nil
end
local subjectPosition: Vector3 = self:GetSubjectPosition()
if self.cameraType == Enum.CameraType.Fixed then
if subjectPosition and player and camera then
local distanceToSubject = self:GetCameraToSubjectDistance()
local newLookVector = self:CalculateNewLookVectorFromArg(nil, CameraInput.getRotation())
newCameraFocus = camera.Focus -- Fixed camera does not change focus
newCameraCFrame = CFrame.new(camera.CFrame.p, camera.CFrame.p + (distanceToSubject * newLookVector))
end
elseif self.cameraType == Enum.CameraType.Attach then
local subjectCFrame = self:GetSubjectCFrame()
local cameraPitch = camera.CFrame:ToEulerAnglesYXZ()
local _, subjectYaw = subjectCFrame:ToEulerAnglesYXZ()
cameraPitch = math.clamp(cameraPitch - CameraInput.getRotation().Y, -PITCH_LIMIT, PITCH_LIMIT)
newCameraFocus = CFrame.new(subjectCFrame.p)*CFrame.fromEulerAnglesYXZ(cameraPitch, subjectYaw, 0)
newCameraCFrame = newCameraFocus*CFrame.new(0, 0, self:StepZoom())
elseif self.cameraType == Enum.CameraType.Watch then
if subjectPosition and player and camera then
local cameraLook = nil
if subjectPosition == camera.CFrame.p then
warn("Camera cannot watch subject in same position as itself")
return camera.CFrame, camera.Focus
end
local humanoid = self:GetHumanoid()
if humanoid and humanoid.RootPart then
local diffVector = subjectPosition - camera.CFrame.p
cameraLook = diffVector.unit
if self.lastDistanceToSubject and self.lastDistanceToSubject == self:GetCameraToSubjectDistance() then
-- Don't clobber the zoom if they zoomed the camera
local newDistanceToSubject = diffVector.magnitude
self:SetCameraToSubjectDistance(newDistanceToSubject)
end
end
local distanceToSubject: number = self:GetCameraToSubjectDistance()
local newLookVector: Vector3 = self:CalculateNewLookVectorFromArg(cameraLook, CameraInput.getRotation())
newCameraFocus = CFrame.new(subjectPosition)
newCameraCFrame = CFrame.new(subjectPosition - (distanceToSubject * newLookVector), subjectPosition)
self.lastDistanceToSubject = distanceToSubject
end
else
-- Unsupported type, return current values unchanged
return camera.CFrame, camera.Focus
end
self.lastUpdate = now
return newCameraCFrame, newCameraFocus
end
I’m probably on the wrong track with that then.
Adding on to what you said earlier, it used to be possible to restore the old camera effect without writing your own script, as shown in a youtube video posted in 2018 by MaximumADHD that I’ll link.
Unfortunately, I believe this was posted before the “2018 PlayerScripts Update”, so the LocalScript called CameraScript no longer appears by default when you run the game.
Also, the update is mentioned in a note at the top of PlayerModule. Full PlayerModule script:
--!strict
--[[
PlayerModule - This module requires and instantiates the camera and control modules,
and provides getters for developers to access methods on these singletons without
having to modify Roblox-supplied scripts.
2018 PlayerScripts Update - AllYourBlox
--]]
local PlayerModule = {}
PlayerModule.__index = PlayerModule
function PlayerModule.new()
local self = setmetatable({},PlayerModule)
self.cameras = require(script:WaitForChild("CameraModule"))
self.controls = require(script:WaitForChild("ControlModule"))
return self
end
function PlayerModule:GetCameras()
return self.cameras
end
function PlayerModule:GetControls()
return self.controls
end
function PlayerModule:GetClickToMoveController()
return self.controls:GetClickToMoveController()
end
return PlayerModule.new()
1 Like
I know I am late to this conversation but you can use this old camera script that I have laying around to achieve the effect using the video.
OldCamera.rbxm (74.9 KB)
1 Like