I’m trying to detect if the player is partially submerged in water as I’m making a system for wading in shallow water (with a splash sound and effect etc) and I can’t figure out how.
I’ve tried looking it up but haven’t had any luck yet, could anyone please help?
If the water is fairly even, and its position is always the same on the Y axis, you could compare the players HumanoidRootPart.Y. If it’s equal or below, they would be submerged in water.
Edit:
And you could do HumanoidRootPart.Y - X, with X being a number, if you wanted to be more specific.
Something like this should do it. You’ll have to experiment with how far down to cast the ray.
local ray = Ray.new(Player.Character.Torso.Position, Player.Character.Torso.CFrame:vectorToWorldSpace(Vector3.new(0, -3, 0))
local hit, position, normal, material = workspace:FindPartOnRay(ray,Player.Character)
if material == Enum.Material.Water then
Splash.Play()
end