Check if character is close to terrain water

Let’s say if you’re just standing 10 studs away from water it’ll detect its near; I need for the character to get the closest distance between it and the water. The water is an irregular shape, of course. Checking if you are on top of the water is easy, its just a raycast down. But near the water is pretty hard. Any of you folks have insight on this?

2 Likes

Best method is to raycast at an angle, or you could just raycast down and shift the ray to the side.

Draw a circle out of voxels relative to the HumanoidRootPart’s CFrame. Then draw down 5 studs.

Reading voxels is pretty fast. You can make some kind of detection shape (i’d use a sphere) and just get the voxels near the character, then iterate through them until you find water. Since voxels are 4x4x4 you only need to update this when the character actually transitions from one voxel to another.

Agreeing with Sharksie and ScriptOn. The most efficient method (as far as I know) would be to use :ReadVoxels().

easiest way is to make an invisible part and calculate studs away from part, not very efficient but works if you’re lazy

1 Like