What solutions have you tried so far?
My code currently deduces the max height where the water will go however it thinks the camera is underwater when it is simply between two waves !
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
local cameraPos = workspace.CurrentCamera.CFrame.Position + Vector3.new(0,2-workspace.Terrain.WaterWaveSize,0)
local x, y, z = cameraPos.X, cameraPos.Y, cameraPos.Z
local min, max = Vector3.new(x + 0.01, y + 0.01, z + 0.01), Vector3.new(x - 0.01, y - 0.01, z - 0.01)
local region = Region3.new(max, min)
region = region:ExpandToGrid(4)
if region then
local material = workspace.Terrain:ReadVoxels(region, 4)
if material[1][1][1] == Enum.Material.Water then
game.Lighting.Blur.Size = 10
game.Lighting.ColorCorrection.TintColor = Color3.new(0.545098, 0.803922, 1)
else
game.Lighting.Blur.Size = 0
game.Lighting.ColorCorrection.TintColor = Color3.new(1, 1, 1)
end
end
end)
local Size = 2
local min = workspace.CurrentCamera.CFrame.Position - (Size * Vector3.new(1, 1, 1))
local max = workspace.CurrentCamera.CFrame.Position + (Size * Vector3.new(1, 1, 1))
I just did it but basically roblox thinks we are underwater when you are between two waves, try to write your material variable, put yourself between two waves, it will show that the camera is well under water !
In the worst case test my code if you want to see my problem, increase the size of the waves and you will see that between two waves the effect is displayed !
I see your problem, The fact that roblox wave are sort of like noise YOu cant just use a number value to sort of approximate the height, Thats why i say you should try use this Sampling Terrain Water Height at Any Position and sample it at the player position
Yes I understand and I looked but it won’t tell me what I want, in reality I want to get a variable that tells me when I’m between two waves that I’m not underwater and my calculation works you can try !
Have a good day, I need to go !
Thank you so much for your help !
If we summarize my code is able to know the height where the player’s camera could be under water, that is to say the maximum height of the waves except that when the waves have passed the effect continues because the camera still believes to be under water !