I'm making some maps for a game and the buildings are meshes that I imported from Blender, and since collisions are super wacky with meshes I'm making them non-collidable and implementing some invisible hitboxes instead. However since the hitboxes are transparent the Camera can go right through them, meaning players can have their camera go behind walls and such. I already found a fix to this which is changing the canOcclude function in one of the player scripts, but the way I did it involved having to reference each individual part, resulting in a very long string of text. Is there any more efficient way of doing this?
Here's what the function looks like at the moment for reference:
local ch = game.Workspace.Map.Cabin.Hitboxes
local cht = {
ch.Hitbox1,
ch.Hitbox2,
ch.Hitbox3,
ch.Hitbox4,
ch.Hitbox5,
ch.Hitbox6,
ch.Hitbox7,
ch.Hitbox8,
ch.Hitbox9,
ch.Hitbox10,
ch.Hitbox11,
ch.Hitbox12,
ch.Hitbox13,
ch.Hitbox14,
ch.Hitbox15,
ch.CouchHitbox1,
ch.CouchHitbox2,
ch.CouchHitbox3,
ch.CouchHitbox4,
ch.TableHitbox,
ch.FireplaceHitbox
}
local function canOcclude(part)
-- Occluders must be:
-- 1. Opaque
-- 2. Interactable
-- 3. Not in the same assembly as the subject
if part == cht[1] or cht[2] or cht[3] or cht[4] or cht[5] or cht[6] or cht[7] or cht[8] or cht[9] or cht[10] or cht[11] or cht[12] or cht[13] or cht[14] or cht[15] or cht[16] or cht[17] or cht[18] or cht[19] or cht[20] or cht[21] then return true end
if FFlagUserPoppercamLooseOpacityThreshold then
return
part.Transparency < 0.25 and
part.CanCollide and
subjectRoot ~= (part:GetRootPart() or part) and
not part:IsA('TrussPart')
else
return
part.Transparency < 1 and
part.CanCollide and
subjectRoot ~= (part:GetRootPart() or part)
end
end

1 comment
This script worked great, thanks!