How can I set the camera to a Collision Group?

Hello, I was making this system showed in the video:

But the problem is that the camera blocks itself if the object is collidable, to explain it better I made another video:

So, to solve it I used collision groups, one for the camera, another one for workspace objects and another one for the Character, because I want the character to collide with objects, but not the camera.

I tried to do this:

RemoteEvent.OnServerEvent:Connect(function(client, camera)
    PhysicsService:SetPartCollisionGroup(camera, "Camera")
end)

But the camera is not a BasePart and any part that is set to a collision group must be a BasePart.

Any help is appreciated, also if there are any questions tell me.

3 Likes

I’m not completely sure what your problem is but it seems like you are talking about the camera not being able to go through the object with its transparency set to 0. This has nothing to do with collision and is actually because of roblox’s default camera controller. You can get this cameraController by playing the game and then taking it from the player scripts. After you copy that and paste it into its appropriate spot you have to edit it to make it do what you want to do.

Hello! I would use raycasting to detect parts between the player and their camera. If you don’t know what raycasting is its basically a line in 3D space that returns information on objects that cross it. Here is some more information about raycasting. Good luck :slight_smile:

I believe this is not something you script. I think there is a property under StarterPlayer or Camera which basically will do what you need.

EDIT: Probably this one

1 Like

I actually had this issue when working on a plane that I was making, I didn’t want the camera to be blocked by the plane when the camera was under the plane. But if I were to do what @octav20071 said, it would ignore every single part in the game which is not what I wanted. So to fix this I had to edit one of Roblox’s CoreScripts. To fix the issue, play test your game and inside of the explorer go to:

StarterPlayer > StarterPlayerScripts > PlayerModule

And copy “PlayerModule.” Once you’ve done this, stop play testing and paste the PlayerModule back into StarterPlayerScripts. Then go to:

PlayerModule > CameraModule > ZoomController > Popper

And scroll down to line 50 where you’ll see a function called refreshIgnoreList(). You can add anything inside of the “blacklist” table that is inside of this function and the camera will totally ignore it. So for example if I wanted to ignore the BasePlate and the BasePlate only, I could replace the function with this:

local function refreshIgnoreList()
		local n = 1
		blacklist = {}
		for _, character in pairs(charMap) do
			blacklist[n] = character
			n = n + 1
		end
		
		table.insert(blacklist, workspace.Baseplate)
	end

You’ll see that the camera ignores the BasePlate and the BasePlate only. You’ll also see that there are two other functions called playerAdded() and characterAdded() just under the refreshIgnoreList() function. These are fired when, well, the player and character are added. So you can customize this module to your liking. Hope this helped!

8 Likes

That’s exactly what I’m using to do the system, but the camera blocks like it’s shown in the second video.

1 Like

Can you show the code for the raycasting? It would help me assist you better.

Thanks for your help, but the problem is not the raycast script, anyways @Master_Aaron already solved it.

Another function that I would like to point out for @Sarchyx is the canOcclude function. You can put your collision groups checking here as well.

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
5 Likes