Custom Camera System ignoring parts and going through walls

Hi, I have a custom camera-related problem.

I’d like to make this custom camera get closer to the character if there is a part in the way, like the default camera.

This is the Localscript I am using, put inside StarterPlayerScripts.

local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
task.wait(1.5)

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function()
    workspace.CurrentCamera.CFrame = CFrame.new(Player.Character.Head.Position.X + 12, Player.Character.Head.Position.Y + 8, Player.Character.Head.Position.Z + 12, 0.752406478, -0.32895574, 0.57067734, -1.49011594e-08, 0.86637032, 0.499402165, -0.658699095, -0.375753433, 0.651862621) 
end)

Here’s an example of this problem I’d like to fix. Notice being able to see the skybox, through a part.

What can I do?

Thanks!

It appears you are not familiar with the concept of PopperCam, which allows the camera to pop in place if an obstruction exists between the player’s head and the camera.

You can find a module related to this by forking it during Play Solo(meaning that you’ll copy-paste the module to learn about it), which contains the code for this behavior.

2 Likes

So I’ve forked the PopperCam module and opened it, and since it’s a module script, I presume I will have to select and work with only a bit of it. What should I do with this code? Do I select some certain parts of it and insert it directly into another script?

(CameraType I’m using is Scriptable, so I think it’s disabled during my playtests)

Think it’s just requiring this and then something something something. I haven’t touched the module for a while and I think you should at least try to learn about its functionality.