Currently, I would like to use the camera occlusion modes Zoom and Invisicam both at different times. This can be set through the property in StarterPlayer.
For example:
When inside a building, use Invisicam
When I go outside that building, use Zoom,
When I enter another building, go back to Invisicam
When I go out of that building, go back to Zoom.
However, I am not aware of any way to set it with a script. How can I set the occlusion mode to either zoom or invisicam in a script by any means possible?
If you set the property on a starterplayer, a player has to rejoin for it to change. Setting DevCameraOcclusionMode does not work because localscripts do not have the permission to change DevCameraOcclusionMode. This unfortunetly doesnt work.
Apologies, I had forgotten that Roblox decides to block access to certain studio features.
You could instead copy the PlayerModule during runtime and paste it back into StarterPlayerScripts, then from there you can edit the Popper module. The Popper module is what controls camera occlusion.
Or, if you want to follow a more external approach, I’ve experimented with ray occlusion in the past. Set up a RenderStepped that runs Camera:GetPartsObscuringTarget(). This is the same approach the Popper module uses.
The dev API even includes a handy function:
local function XRay(castPoints, ignoreList)
ignoreList = ignoreList or {}
local parts = workspace.CurrentCamera:GetPartsObscuringTarget(castPoints, ignoreList)
for _, part in pairs(parts) do
part.LocalTransparencyModifier = 0.75
for _, child in pairs(part:GetChildren()) do
if child:IsA("Decal") or child:IsA("Texture") then
child.LocalTransparencyModifier = 0.75
end
end
end
end
The only cast point should be {char.PrimaryPart.Position} (casts ray from cam to character)
Setting the local transparency to .25 (or greater) will allow the camera to clip through.
Edit: Make sure the character is inside the ignore list.
Hope this helps!