Endless Ground Generation

For context: I’m trying to recreate a game called Dead Rails, where it has endless Ground -generation.

However, I wanna make whenever the player gets close, it creates new grounds.
image

My first solution is to have the ground be apart of the rails, but since the rails can be rotated, it would have a lot of z-fighting.

Any ideas?

I didn’t understand your problem

1 Like

Sorry if my wording was wrong, think of the ground as a baseplate. Whenever the player gets close to the edge of the baseplate, it creates a new baseplate that would be infront of the previous baseplate

I’m not sure you’re problem either.

You can just check the previous size x value and have it subtract or add .001, with a math.clamp to prevent stuff from getting to low or high.

Perosnally, since the texture on the baseplate is an 8x8 texture (if im not mistaken) i would do something like this:
It doesnt generate ground but it keeps the ground positioned around the player

local Base = game.Workspace.BasePlate
local RunService = game:GetService("RunService")
local GridSize = 8

RunService.Heartbeat:Connect(Function()
    if not game.player.LocalPlayer.Character then return end
    if not game.player.LocalPlayer.Character.HumanoidRootPart then return end
    local PlayerPos = game.player.LocalPlayer.Character.HumanoidRootPart.Position

    local NewPos = vector3.new(math.round(PlayerPos.X / GridSize) * GridSize, Base.Position.Y, math.round(PlayerPos.Z / GridSize) * GridSize)
    Base.Position = NewPos
end)
1 Like

if you want an easy solution, just make a part at the end of some rails, and when the part is touched, put more rails in front.

local touchPart = game.Workspace.Part
local endPart = game.Workspace.EndPart

touchPart.Touched:Connect(function()
  local newRail = script.Rail:Clone()
newRail:PivotTo(endPart.CFrame)

touchPart = newRail.part
endPart = newRail.endPart
-- just example, but you get it
end)