You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Part of my game just randomly dissapears depending on the angle -
What is the issue? Include screenshots / videos if possible!
video. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t found much.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
game:GetService("RunService").RenderStepped:Connect(function(deltaTime: number)
MAX_AMPLITUDE = MAX_AMPLITUDE + (targetMaxAmplitude - MAX_AMPLITUDE) * 0.1
NOISE_AMP = NOISE_AMP + (targetNoiseAmp - NOISE_AMP) * 0.1
if isSplashing then
splashTime += deltaTime -- Assuming ~60fps
if splashTime >= 2 then -- End splash after 2 seconds
isSplashing = false
end
end
targetMaxAmplitude = targetMaxAmplitude * 0.99
targetNoiseAmp = targetNoiseAmp * 0.995
WAVE_OFFSET = WAVE_OFFSET - deltaTime
debug.profilebegin("updateVertices_Water")
updateVertices(WAVE_OFFSET)
debug.profileend()
workspace:WaitForChild("Water"):ApplyMesh(game:GetService("AssetService"):CreateMeshPartAsync(Content.fromObject(EditableMesh)))
end)
updateVertices()
:
local function updateVertices(offset)
for i = -GRID_SIZE, GRID_SIZE do
for j = -GRID_SIZE, GRID_SIZE do
local index = getVertexIndex(i, j)
local currentPosition = EditableMesh:GetPosition(index)
local x, z = i/GRID_SIZE, j/GRID_SIZE
-- base wave
local wave1 = math.sin(x * 3 + offset * 1.2) * 0.3
local wave2 = math.sin(z * 2.5 + offset * 0.8) * 0.4
-- ripple from coords
local distanceFromCenter = math.sqrt(x^2 + z^2)
local ripple = math.sin(distanceFromCenter * 8 + offset * 1.5) *
math.exp(-distanceFromCenter * 0.8) * 0.5
-- fractal noise
local detailedNoise = createWaterNoise(x, z, offset, 1.0) * NOISE_AMP
-- add splash effect if on
local splashEffect = 0
if isSplashing then
local distFromSplash = math.sqrt((x - splashPoint.X)^2 + (z - splashPoint.Y)^2)
local splashWave = math.sin(distFromSplash * 15 - splashTime * 8)
* math.exp(-distFromSplash * 2 - splashTime * 2)
splashEffect = splashWave * 2 * (1 - splashTime/2)
end
local height = (wave1 + wave2 + ripple) * MAX_AMPLITUDE
height = height + detailedNoise + splashEffect
EditableMesh:SetPosition(index, Vector3.new(
currentPosition.X,
height,
currentPosition.Z
))
end
end
end
(i do this thing where i run my code through iterations. this is the first iteration. where performance isnt the main concern. i just want it to run my code.)
also this is my first post on the forum!
and i dont know if this is the right topic.