i want to create an infinite ocean
i have a skinned mesh ocean its 3x3 grid of them (each part is 2046 by 2046) i also have a 5x5 one if its needed
i tried checking which part is closer to the player and moving the ocean like that but it didnt work
if you know another way to make an infinite ocean or fix mine help is appreciated.
local currentWave = nil
local oldWave = nil
local Waves = workspace:WaitForChild("Waves")
while true do
task.wait(5)
for i, v in pairs(Waves:GetChildren()) do
if currentWave then
if v.Position > currentWave.Position then
oldWave = currentWave
currentWave = v
else
oldWave = currentWave
currentWave = v
end
end
end
if currentWave ~= oldWave then
Waves:PivotTo(currentWave.Position)
end
end
Keep a table of which tiles are loaded. Anytime the player moves, check if they are now in a new tile. If they are, re-calculate which tiles should be loaded (e.g. 10 tiles in each direction). Compare those tiles to the ones in your loaded tiles table to determine which ones to load and unload.
I have a game that does something similar you can check out: UNL Demo Place - Roblox.
Look in ServerScriptService.Terrain.TerrainGenerator
local currentWave = nil
local Waves = workspace:WaitForChild("Waves")
local player = game.Players.LocalPlayer
local character = player.Character
while true do
task.wait(5)
for i, v in pairs(Waves:GetChildren()) do
if v:IsA("MeshPart") then
if currentWave then
if (character.PrimaryPart.Position - v.Position).magnitude < (currentWave.Position - character.PrimaryPart.Position).magnitude then
currentWave = v
end
else
currentWave = v
end
end
end
Waves:PivotTo(currentWave:GetPivot())
end