How could I make an effective multiplayer origin shifting system?

Hence the title, I want to know how I could make an effective origin shifting system for a randomly generated chunk map, kind of like how Minecraft does it excluding the individual blocks.

For those who don’t know what that is, basically origin shifting is a process where you move the map around the player in a way to return the actual players position to the center. The reason this is done is to avoid bug with floating point precision, which is an issue pretty much all engines struggle with.

To elaborate further, floating point precision loss is when you have extremely large floating point numbers, meaning it has less resources to give accuracy to the number since it is so large.

My goal is to create a extremely large randomly generated map as stated before, possibly infinitely scaling so players have a large amount of freedom. Any suggestions on how to make origin shifting effective in this matter, especially considering multiplayer?

If you make a multiplayer game, won’t you have to replicate the map to every single player, then handle it locally to center the replicated map to the player?

From my experience, floating point rendering issues only start at 50000 studs and above. If your map is above that I’m not sure if it is possible to origin shift the whole thing to make the player at the center.

Plus, if you are going to make the map editable (like Minecraft), you will have to synchronise the maps across all the players, right?

I am also not sure if this is even possible with Roblox’s engine. For games like Minecraft, Mojang can edit how the map is loaded/processed directly, but I am not sure if you can do that in Roblox.

If you could find a workaround (like locking the player to the origin and then watching their inputs to move the surrounding map) I am also pretty sure Roblox limitations and network lag between players would cause some issues.

Edit: After reading your post again I have some more considerations for you:

  1. If your map is infinitely generating, the performance cost of origin shifting the map will increase proportional to its size. (Eventually once the map gets big enough things will shut down because of performance limits)

  2. If your map is infinitely generating, you will have to find a way to store it. I have seen very big Minecraft maps go to 1GB+, and I don’t think you can do that with Roblox.

  3. If your map is based on cubes and you plan on origin shifting them, I don’t think that is possible. From my experience, about 15 million parts is enough to lag the game on an okay-ish computer, so you must keep that in mind.

  4. If you split the world into chunks and move those, you will have to implement something similar to how Minecraft does chunk (part register, …) and only origin shift the relevant chunks. You might also need to keep some sort of record of the absolute positions of the map so you don’t lose track of things. In addition, I have heard some people talk about how chunks should have their own local positions and such. I’ve also seen that games like Minecraft that you mentioned still suffer from the floating point problem (farlands, stripelands in Bedrock), and in the stripelands there are also rendering issues somewhat like their are in Roblox. (1)

  5. If you origin shift I am pretty sure any currently moving physics objects will be flinged and cause problems.

(1) if you wish to know more about the stripelands, I found this short that explains it pretty well: https://www.youtube.com/shorts/gIba2fB_eWw

As long as you are not creating instances on the server, but rather keep players as data on the server, you can create instances for the players on the client just relative to you. I think the largest pain point would be shifting the map. Of course the map is only drawn on the client, so you can move it with maybe a batch cframe, or another idea, allow the player to move normally, but after they reach a certain distance from origin, snap them back to origin, and shift the map accordingly. This way its not shifting each frame. Sounds like a fun thing the play with. Hope you get it working.

So I’ve read your post, and I agree with you that this could be hard and possibly also impossible, at least with the limitations of Roblox Studio.

Now I didn’t want to make the players be able to mine the individual blocks, as its not really supposed to be a terrain based game like Minecraft or Astroneer, but shifting an entire map in itself now thinking about it is kind of insane.

I was planning on using stuff like Level Streaming, and possibly only caring about the chunks near the player, meaning the amount needed to shift would be not as much which could soften the load, as you also suggested.

But that still doesn’t change the fact that origin shifting with multiplayer is extremely difficult. Now I also probably would make it so worlds wouldn’t really get saved, being just a random world each server you go into, I wasn’t planning on being able to return to them at all.

So realistically origin shifting in itself is fine, its really the multiplayer that’s the issue, which is good to keep in mind since that could be useful for other single player projects but its unfortunate that’s how we are limited right now.

I do thank you for your response though, do you have any suggestions how I could make the map feel bigger though?

I’m considering just dropping the origin shifting entirely and limiting the map, but make it as large as possible while trying to avoid seeing any floating point precision loss. I know I could make the player smaller and the actual environment smaller, for a miniature / replica solution, meaning the map could have the same limitations but still be bigger to the players.

The issue with that though, is making the player smaller, as well as the environment causes some issues specifically with the Roblox engine, since the player isn’t really supposed to be small. This includes the camera being cursed (which could be fixed). Along with this though the humanoid just kind of freaks out when its so small.

And for the environment, well all of the textures would be scaled up for us like crazy, since we are so small. Roblox textures don’t scale with the part size, as you know, which could break the immersion.

Nonetheless, thank you for your response. There is a lot of things to consider so I appreciate you helping me out.

You may want to focus on chunk streaming, local client visuals, and perceptual tricks to make the world feel large. For single-player experiments, origin shifting works fine; multiplayer requires careful compromises.

Could you explain a bit more what sort of a game you’re looking to use this for? That vast majority of games would never need such a system, and those that would (maybe) justify the effort can call for drastically different approaches depending on design requirements.

Also, I’m not sure how much Minecraft actually actively does in terms of attempting to account for floating point issues at high distances.

Currently, I think the best idea for you to implement is to add map regions, and you being able to save each region’s data so you can track where the player is and where the region is.

Furthermore, the miniature solution is also a good idea, I have found that isometric view games (RTS) make the map look much bigger by making the player smaller.

For example, you can make a scale of 1:10000 to the real map you want. This is how maps are made in real life, one potential downside is the loss of detail.

For the multiplayer part, I think you CAN do it, with great difficulty, by making a lot of events and buffers/handlers and design a system of mathematical self-tests, so that all clients remain in sync.

They’re probably making an open-world game, because in that world players usually go out pretty far to explore and stuff.

As for how Minecraft deals with floating point errors, that’s the topic of this post (origin shifting and chunking). However, from my experience Minecraft even with all of these methods still has floating point errors.

I found this video that illustrates the limitations in more detail, with positioning labeled and stuff:

The deal is: with Minecraft, developers can edit the graphics engine and the positioning algorithm directly, while in Roblox those things are off limits. (Probably for good reason because making a mistake will brick the engine)

The only thing I can find similar to engine shifting in Roblox is just setting the part’s position back in a certain direction (one farthest from origin) by an offset. In Minecraft I think they change how the rendering engine looks at positions themselves (camera relative)

I’ve also seen some people say that individual chunks have local origins and block registers (I’ve seen some glitches with randomizing blocks by overloading the register)

What limitations of Roblox Studio? I keep hearing this.. The only limits is how well you code, and how well you understand a given technique..

“For those who don’t know what that is, basically origin shifting is a process where you move the map around the player in a way to return the actual players position to the center. The reason this is done is to avoid bug with floating point precision, which is an issue pretty much all engines struggle with.”

You want to move the whole map vs moving the player? I think you’re talking about this
(x′,y′)=(x−x0​,y−y0​), but I’m not sure..

Is this even close to what you’re looking to do here..

Example
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local SHIFT_THRESHOLD = 500

RunService.RenderStepped:Connect(function()
    local char = player.Character
    if char and char:FindFirstChild("HumanoidRootPart") then
        local hrp = char.HumanoidRootPart
        local offset = hrp.Position
        if offset.Magnitude > SHIFT_THRESHOLD then
            for _, obj in ipairs(workspace:GetChildren()) do
                if obj:IsA("BasePart") and obj ~= hrp then
                    obj.Position = obj.Position - offset
                elseif obj:IsA("Model") then
                    obj:TranslateBy(-offset)
                end
            end
            hrp.CFrame = CFrame.new(0, hrp.Position.Y, 0)
        end
    end
end)

Not exactly my friend!

You see, Roblox Studio is what I call a high level game engine, this means that the developer cannot interact directly with the hardware. With other games that do not use a game engine at all, the devs have much much more control.

It also means that you cannot change the positioning engine, the graphics engine, etc.

Yes, you can make workarounds, but for extremely large amount parts it’s going to be a problem. If your map is so big you need to origin shift, there will be a lot of parts!

AND, if you work in multiplayer, you will have to sync the absolute and local position datas to other players and to the server, otherwise every local player will be in a different position relative to the same object even though they are in the same absolute space.

Also, there will be some hard limits no matter how well you code due to the engine itself, Roblox is very easy to learn but because of that it’s also very limited.

To be honest, I’m not even sure what you mean by origin shifting. I take it you mean floating origin.
I took a guess, and it didn’t work out. :face_with_crossed_out_eyes: I’ve done this in Unity, but I guess it’s not totally the same here.

It just seems like calling things Roblox limitations is not pushing hard enough. You’re not going to find out of the box thinking in AI. I’ve never really ran into anything here I haven’t figured out a way around, so I’m not really feeling the limitations yet.

Ah, well yeah it’s basically the same to Unity. They wanna origin shift in Roblox so the only way to do that is basically the code snippet you gave but for the threshhold to be much higher, at like 50000 studs or something.

The difference is with Unity you can tweak more stuff and have more control, that’s all!

Ok test this out .. when you spawn you will see a red box in front of you.. walk past it..
You’re not going to notice what just happened, but it will float the origin.. check your position.
FloatingOrigin.rbxl (59.5 KB)

Terrain is a special object, however, and you can’t toss that in the World Model.
For that, you’ll need a landscape generator working off chunk math.

I’m not sure what they are all working with and I need hands on to debug things.

The terrain part is the limitation I’m talking about, and yep your implementation is exactly right!

The problem is they’re probably not dealing with 1 part, but thousands if not millions, because they did say their map would be big.

Another problem left is the replication between clients, and that’s it!

Its been a while since I have checked out this Topic, but can’t you control robloxes camera with a decent amount of flexibility in studio?

I’m not fully sure on what

Fully means, but is what I’m talking about possible?

I think you can mess with the player camera a lot, but maybe shifting the physical parts instead may be easier and less glitchy.

Yeah, I was thinking of having a pretty large map, and its not just one massive part as you’ve guessed. Since it was planned to be randomly generated, it would be a lot of stuff.

But honestly the biggest issue is replication, because origin shifting the entire map would be more a efficiency issue, but replication would be actually something crazy to try to make.

I think it would fit for some kinda singleplayer game!

I found a solution for my space game that might work for your game:

  1. Create an anchored copy of your characters at position them at 0,0,0 and make all real characters invisible.
  2. Create a local script to make the anchored copy mimic your real character’s animations but stay exactly at the origin while everything else (the map) shifts around it including other player’s fake characters.

The reason why it must be anchored is to beat Roblox’s server authoritative physics, if a local script tries to set a position of an unanchored object, the server will override it (Unless you set a Network Ownership).

Would you possibly be able to explain more? I’m a little confused.
It sounds like whatever you’re saying is a good idea but I’m not fully understanding what you’re saying.