Is it possible to make the character visible through the tree so say a small circle round where you character is and remove anything from where the camera is to the character, tell me if you need me to explain it better?
I’d suggest you look into Highlights, you can place a Highlight around the player’s character when it’s currently hidden by an object. Then you can use raycasting in order to check if the character is currently hidden by an object.
Do you know how i would send a raycast from the players camera as its not a part?
Hi, sorry for the late response. Cameras have a property named CFrame which returns a CFrame value of its current CFrame.
CFrames have a property inside of them named “Position” which returns a Vector3 of their current position. You can use this position in order to raycast.
Hey, I’ve just been trying to do it with someone else, ill paste the code as he had to go and we couldnt get it to work?
local zoom = 140
local FieldOfView = 7
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
if Character then
if Character:FindFirstChild("Head") then
game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, Character.Head)
Camera.CFrame =
CFrame.new(Vector3.new(Character.Head.Position.X + zoom, Character.Head.Position.Y + zoom, Character.Head.Position.Z + zoom), Character.Head.Position)
end
end
end)
while true do
wait (1)
local CPart = workspace.CameraPart
game.ReplicatedStorage.MovePart:FireServer(Camera.CFrame)
local hrp = Player.Character.HumanoidRootPart
local rayOrigin = CPart.Position
local rayLength = math.round((Camera.CFrame.Position - hrp.Position).Magnitude)
local rayDirection = (hrp.Position - CPart.Position).Unit
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {hrp.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
print(raycastResult.Instance)
game.ReplicatedStorage.Highlight:FireServer(Character.Highlight,true)
else
game.ReplicatedStorage.Highlight:FireServer(Character.Highlight,false)
end
Camera.FieldOfView = FieldOfView
end
I’ve just found another solution which is using the Camera’s function named GetPartsObscuringTarget which is what Roblox’s Invisicam
uses in order to make objects transparent when this setting is turned on.
I’m sorry if I didn’t tell you this earlier, but Roblox has a feature named Invisicam
which does the job for you, it sets the part’s transparency instead of setting a Highlight
around the player.