Hello! I was wondering how I could make objects too close to the camera that blocks it’s view disappear and then reappear once it is out of the way.
For example, lets say there is a big tree. I walk behind the tree and it blocks the view of the camera. Is there anyway to make the tree invisible so that way I can see through it? Also I would like it to reappear once it is not blocking the view.
Simple, sorry I didn’t read this. Then you need to use and get the player’s HumanoidRootPart CFrame, and calculate it from there. I thought you where talking about a ViewPort. This would look like this;
--//Services
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--//Variables
local Player = Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local Folder = game.Workspace.Folder -- has parts I guess..
--//Main
RunService.RenderStepped:Connect(function(dt)
for i,v in pairs(Folder:GetChildren()) do
if Camera:WorldToViewportPoint(v.Position) then
if (Player.Character.HumanoidRootPart.Position - v.Position).Magnitude <= 10 then
v.Parent = ReplicatedStorage.Folder -- some object to parent it to other than WS
end
end
end
--loop to bring em' back
for i,v in pairs(ReplicatedStorage.Folder:GetChildren()) do
if (Player.Character.HumanoidRootPart.Position - v.Position).Magnitude > 10 then
v.Parent = Folder -- back to workspace!
end
end
end)
Is the native version of this not sufficient enough for you? If you set StarterPlayer.DevCameraOcclusionMode to Invisicam, it automatically makes parts translucent when they’re blocking your camera. I don’t believe there is a whitelist for it though to make exceptions (thus combining zoom and invisicam), so that might be worth an investigation.
I also want it only if it is a certain distance from the camera, not all parts. Plus I want it to be semi transparent. I actually have found I great forum on it!