I made a tiled water mesh in Blender with a displacement texture. What I want to do is make a bunch of them tile around the player and constantly move in a certain direction until they are far away and show up on the other side to give an impression of rippling water. If you’ve played games like Blox Fruits that have infinite scrolling water, I’m trying to do that but with meshes, not textures. I tried typing up a script but I couldn’t come up with a way to make each tiled scroll without referencing clones individually.
Are you looking for a way to dynamically tile and move multiple instances of your water mesh around the player in a game environment, similar to the infinite scrolling water effect seen in games like Blox Fruits?
-- Define variables
local waterTile = game.Workspace.WaterTile -- Reference to the water tile model
local player = game.Players.LocalPlayer -- Reference to the local player
local tileSize = 10 -- Size of each water tile
local tileCount = 3 -- Number of tiles to have around the player in each direction
local tiles = {} -- Table to store references to spawned water tiles
-- Function to spawn water tiles
local function SpawnWaterTiles()
for x = -tileCount, tileCount do
for z = -tileCount, tileCount do
local newTile = waterTile:Clone() -- Clone the water tile model
newTile.Parent = game.Workspace -- Set the parent to the Workspace
newTile.Position = Vector3.new(x * tileSize, 0, z * tileSize) -- Set the position of the new tile
table.insert(tiles, newTile) -- Add the new tile to the tiles table
end
end
end
-- Function to update water tiles based on player position
local function UpdateWaterTiles()
local playerPos = player.Character and player.Character.HumanoidRootPart.Position -- Get player position
if playerPos then
for _, tile in ipairs(tiles) do
-- Calculate distance between player and tile
local distance = (playerPos - tile.Position).magnitude
-- Check if tile is far enough from player to be moved to the other side
if distance > tileSize * tileCount * math.sqrt(2) then
-- Move tile to the other side
local offset = playerPos - tile.Position
tile.Position = tile.Position + offset
end
end
end
end
-- Call the functions
SpawnWaterTiles()
game:GetService("RunService").RenderStepped:Connect(UpdateWaterTiles) -- Update water tiles every frame
This script assumes you have a model named “WaterTile” in your Workspace that represents the water mesh. Adjust the tileSize and tileCount variables to fit your desired tile size and number of tiles around the player.