Skip to content

Instantly share code, notes, and snippets.

@Quenty
Created August 29, 2019 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Quenty/75d39d43fd8b8d92eedf31954782f6d5 to your computer and use it in GitHub Desktop.
Save Quenty/75d39d43fd8b8d92eedf31954782f6d5 to your computer and use it in GitHub Desktop.
IgnoreCameraClient.lua
--- Utilizes a hack to force the popper camera to blacklist the parts in question
-- @classmod IgnoreCameraClient
-- @author Quenty
local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))
local RunService = game:GetService("RunService")
local HttpService = game:GetService("HttpService")
local BaseObject = require("BaseObject")
local IgnoreCameraClient = setmetatable({}, BaseObject)
IgnoreCameraClient.ClassName = "IgnoreCameraClient"
IgnoreCameraClient.__index = IgnoreCameraClient
function IgnoreCameraClient.new(obj)
local self = setmetatable(BaseObject.new(obj), IgnoreCameraClient)
self._parts = self:_getDescendantParts()
self._key = HttpService:GenerateGUID()
self._transparencyMap = {}
-- This is a hack to get the camera to blacklist the currently dragged part
RunService:BindToRenderStep(self._key .. "_preupdate", Enum.RenderPriority.Camera.Value-1, function()
self:_setTransparency()
end)
RunService:BindToRenderStep(self._key .. "_postUpdate", Enum.RenderPriority.Camera.Value+1, function()
self:_resetTransparency()
end)
self._maid:GiveTask(function()
RunService:UnbindFromRenderStep(self._key .. "_preupdate")
RunService:UnbindFromRenderStep(self._key .. "_postUpdate")
end)
return self
end
function IgnoreCameraClient:_setTransparency()
for _, part in pairs(self._parts) do
if not self._transparencyMap[part] then
self._transparencyMap[part] = part.Transparency
end
part.Transparency = 1
end
end
function IgnoreCameraClient:_resetTransparency()
for part, original in pairs(self._transparencyMap) do
part.Transparency = original
end
self._transparencyMap = {}
end
function IgnoreCameraClient:_getDescendantParts()
local parts = {}
for _, part in pairs(self._obj:GetDescendants()) do
if part:IsA("BasePart") and part.CanCollide and part.Transparency < 1 then
table.insert(parts, part)
end
end
return parts
end
return IgnoreCameraClient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment