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?
raycast straight down from the players torso, and if the ray hits water then play the sound or change the SoundId of the footsteps sound.
That’s the first thing I tried. Didn’t work
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.
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
i forgot that there was a material under findpartonray, I overcomplicated it… It works now, thanks.