I want to be able to make it so that the player’s camera can go through many specific parts without lagging, or using invisicam since that makes the parts transparent and does not let you decide on which parts are look-through.
Have you looked at previous Devforum threads regarding the same topic?
Yes, I have looked at some of them, where half of them tell people to use invisicam and the other half tell people to do the transparency-0.25 trick, but I don’t want to use that method since I want to be able to switch these look-through parts at a large scale, so I don’t want to risk any lag or make the system very messy.
What have you previously concluded?
I have scanned through the default camera script, (PlayerScripts.CameraModule) but cannot find the part where I could customize the behaviour when the camera is occluded.
The main question in this topic is, where is the camera-occlusion code in the camera scripts?
Note: This is my first post after my introduction post, so please don’t be too critical.
Edit: I need the camera to be able to look through parts with CanCollide on and parts that are opaque.
It hurts to say this but using Invisicam might be your best bet. To make a lot of parts translucent at such a large scale you cannot simply avoid lag. Unless you make your own type of script that only makes parts near the player’s camera translucent, that would also work but might not be what you want.
You can get a camera’s world position to make parts near the camera invisible. Just remember that different types of instances have different ways of being transparent. Like models you’ll need a for — do loop. Just for an example.
Thanks for the amazing response!
I think you misunderstood me a little bit. What I am trying to achieve is shown in the video I attached. This is me using the other methods that I do not want to use for certain reasons.
I want the player to be able to move the camera through the part but not for the part to be transparent, translucent, invisible, etc.
You can put the part CanCollide property to false; By that, the camera will be able to go through.
If you want the player (or any other Instances) to be able to collide with the part, you should use PhysicsService.
An easy way to change this is to copy the PlayerModule and change the “canOcclude” function in the “Popper” module script located in PlayerModule > CameraModule > ZoomController
local function canOcclude(part)
-- Occluders must be:
-- 1. Opaque
-- 2. Interactable
-- 3. Not in the same assembly as the subject
return
getTotalTransparency(part) < 0.25 and
part.CanCollide and
subjectRoot ~= (part:GetRootPart() or part) and
not part:IsA("TrussPart")
end
This is very helpful, Here is a tip for those who can’t figure it out.
Playtest in studio, find Players > Your Player > Player Scripts > Player Module and Copy that. Stop the playtest and paste it into StarterPlayerScripts. Then in the Popper Module canOcclude function you can do something on the lines of this, or to fit your game better:
local function canOcclude(part)
-- Occluders must be:
-- 1. Opaque
-- 2. Interactable
-- 3. Not in the same assembly as the subject
if part:FindFirstChild("CamIgnore") then
-- I put a value called CamIgnore in parts I dont want the camera hitting
return false
end
return
getTotalTransparency(part) < 0.25 and
part.CanCollide and
subjectRoot ~= (part:GetRootPart() or part) and
not part:IsA("TrussPart")
end
-- return false for the camera to go through it, return true to make it hit it
You can make two identical parts in the same location. One that is invisible and that has collisions on, and another one that is visible but collisions off. The camera is going to go trough the collision part because it is transparent, and its going to go trough the visible part because collisions are off. That does the trick for me