How to detect when player camera is underwater

Hey I’ve been reading this thread since it started but I couldn’t reply as I wasn’t a member yet :grimacing:
Not to be cold or anything but I’m pretty sure this is impossible due to a lack of functions for Roblox water.
Also like I have literally never seen this done before. In the game you showed roblox waterpark I went around testing the system but it seemed to just all be triggers located in the water. As there are some pools of water that don’t work unless I put my camera further in and then stopped working once my camera went further into the water.
Personally, if I was you I’d make my own custom water or something.
Obviously I’m not a professional for all I know maybe there is a way to detect if something is colliding with water but I’m pretty sure it’s just not possible to do it accurately.

4 Likes
while wait() do
	local pos = cam.CFrame.Position

	local min = Vector3.new(pos.X + offset,pos.Y + offset, pos.Z + offset)
	local max = Vector3.new(pos.X - offset,pos.Y - offset, pos.Z - offset)
	
	local region = Region3.new(max, min)
	region = region:ExpandToGrid(4)

	if region then
		local material = game.Workspace.Terrain:ReadVoxels(region, 4)
		if material[1][1][1] == Enum.Material.Water then
end
end
1 Like

this is a great idea, if u can detect water using overlap params then that would be sufficient, so the part size would be 0.1, 0.1, 0.1 or just a small circle using overlap params but if overlap cant detect water which i think is true then gg, maybe read voxels but idk if that method is delayed cuz of how mid the terrain optimizations are

You bumped it. :sad:
Also, I’m not an advanced scripter, so, I dont know what to say.
But thanks for giving the help!
Dev was here in 2024

i know im not the owner of this