Theres a community resource of a formula to approximate roblox height
I don’t understand what you mean :
…
I mean roblox wave height try search for it
I have already managed this on my own but what happens is that roblox believes that have is under water while have is between two waves!
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 !
It does not work …
but thanks for the 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 !
No that’s not what I want!
But I think the thing I send @tin_nim doesn’t match what I’m looking for tell me if I’m wrong!
THe module i send to you should be putted into a module script, And should be required and called, with the camera.CFrame.Position in a localscript, Plus the thing you said that the camera still believe its underwater, That is because you’ve got 1 fixed position for water height, That does not account for wave and such, DO you even read the link i sent to you?
Yes it’s okay sorry I’m long to understand !
Thank you so much !
But on the other hand I don’t understand how to use it to know if the camera is underwater or not, sorry I’m new!
I need to recover which variable of the module for know if I am underwater (the cam) ?
Look at the documentation of the module
--top of your code
local mod = require(pathtomodule)
--In the code you want to get the water height
local x = positionofcamerax
local z = positionofcameraz
local waterheight = mod.calcWaterHeightOffset(x, z)
So I’ve do this, now how do i use it (sorry if I’m asking too much) ?
local RunService = game:GetService("RunService")
local mod = require(game.ReplicatedStorage.WaterHeightCalculator)
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 x = cameraPos.X
local z = cameraPos.Z
local waterheight = mod.calcWaterHeightOffset(x, 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)
It’s good I understand, thank you for your help it was very useful to me !