Fix parts being offset in online mode by replicating rotations with full precision

I’m not sure I understand what optimizing the game has to do with the problem - can you explain this a bit more?

It seems to happen with all large parts that I’ve seen (or rather, it happens with all parts but gets far more noticeable as the parts get larger), including anchored ones - of course, the vast majority of them have a rotation other than 0,0,0.

Edit: I changed the title to specify rotations instead of positions.

The tracks are in segments so for straight aways if I made it 1 segment rather than multiple it would use less parts and textures. However by doing this I also increase the amount the part will offset in the actual servers of the game due to floating point errors. This then causes the cars to bounce and fly off the track since it has a .005 or .002 offset. In studios though. the parts are perfectly aligned no offsetting. Bigger parts = more offsetting.

They have both I have some parts with zero rotation then others with some rotation.the offsetting is the position though. Ever since roblox removed .000 in rotations and changed it to .00 I have not had to worry about the rotations offsetting.

I reported this as well somewhere else but I can’t remember where, but same here:

Studio:

Online: image

These are two rails connected to eachother (they have rotation applied to them), but the bigger the rail, the bigger the offset becomes online (and it’s a real pain)

2 Likes

Thread you are referring to: Parts shifting ingame

1 Like

Someone also posted a image of the issue as well which if needed I can do the same thing.

!!!

So this was why my miniature airports were buried far from the origin point despite no script changing them and being perfectly fine in studio!

Yes although no staff members have mentioned anything about fixing it still :confused:

@zeuxcg is there anything you guys can do about the issue with positions not being accurate in servers? This is heavily effecting my game and I am sure any other games with vehicles have problems with this as well like vehicle simulator, Ultimate driving, Drive shaft, and other games.

2 Likes

Once again, positions should be preserved with full accuracy. Rotations can be off. If you have parts that have Rotation 0,0,0 and they look off feel free to submit this as a bug report. With regards to rotation, we’d need to investigate whether this is viable at all - the extra bandwidth requirements of a full transform are pretty substantial.

2 Likes

Who would I report this or send the file to? Also thank you for your time and patience.

You can use the Bug Reports category for this. If you don’t have posting access, then you can send a group-PM to @Post_Approval.

I’m not sure who you can send files to if you only want staff to see them. You can make a private place though and link it – staff can access those. It’s generally preferred that you make a minimal reproduction of the issue, though, which should be fine to share with others and include in your public bug report post.


You might be able to work around this bug. For all of the parts you want full precision for, you can experiment with putting CFrameValue objects in them on the server, then reading those and setting their CFrames using those on the client.

If the rotation of CFrameValue objects is not preserved with full accuracy, then you can experiment with sending the lookVector and upVector of the objects’ CFrames.

Here is some untested example code
local CollectionService = game:GetService("CollectionService")

local function markAsFullReplication(part)
	local v = part:FindFirstChild("FRLook") or Instance.new("Vector3Value")
	v.Value = part.CFrame.lookVector
	v.Name = "FRLook"
	v.Parent = part
	local v2 = part:FindFirstChild("FRUp") or v:Clone()
	v2.Value = part.CFrame.upVector
	v2.Name = "FRUp"
	v2.Parent = part
	CollectionService:AddTag(part, "FullReplication")
end

local function lookUpToCFrame(position, look, up)
        -- you might need to flip `look` somewhere (i.e. `-look`)
	local right = up:Cross(look)
	return CFrame.new(
		position.x, position.y, position.z,

		right.x, up.x, look.x,
		right.y, up.y, look.y,
		right.z, up.z, look.z
	)
end

local function handleFullReplicationParts()
	if game:FindService("NetworkServer") then
		local function forPart(part)
			markAsFullReplication(part)
		end
		for _, part in next, CollectionService:GetTagged("FullReplication") do
			forPart(part)
		end
		CollectionService:GetInstanceAddedSignal("FullReplication"):Connect(forPart)
	elseif game:FindService("NetworkClient") then
		local function forPart(part)
			coroutine.wrap(function()
				part:WaitForChild("FRLook")
				part:WaitForChild("FRUp")
				part.CFrame = lookUpToCFrame(part.Position, part.FRLook.Value, part.FRUp.Value)
			end)()
		end
		for _, part in next, CollectionService:GetTagged("FullReplication") do
			forPart(part)
		end
		CollectionService:GetInstanceAddedSignal("FullReplication"):Connect(forPart)
	end
end

handleFullReplicationParts()

Sadly there is no way to reproduce the issue since it just happens. Like no matter what game I make or play I notice the offsetting and this has been going on since like 2011.

It is how ever for me only the positions not the rotations since roblox changed .000 rotation to .00 only

JFYI we’ve just enabled a change that increases the precision of rotation replication by fixing a bug. (the change is live on Windows and Mac only, in desktop players - not in Win10 app or mobile yet, these just haven’t upgraded - the change will ship there in a week or so).

In theory rotated parts should align better in general now. We still are not using full precision rotation replication but I’m curious if any places posted here got better? If they didn’t it would also help to see models that showcase the portions of the places that have this issue, e.g. two rail segments that are misaligned etc.

5 Likes

Definitely looks a lot better! I don’t have any previous screenshots to compare with, but I should still be able to give a good idea. This is the seam in a fairly extreme example now, where it’s perfectly aligned in studio:

Part Seam

I’m not joking when I say this is a fairly extreme example, either - the two parts there have one of their size axes pretty much maxed out. I was trying to build a mile-tall tower or something with the scale of 2.5 studs to the metre. Don’t ask.

Edit: Fixed grammar.

The shift is definitely still there, but at least it’s a lot less

I can confirm that it’s a lot less now. The rails are not overlapping eachother anymore, instead they’re just offset ever so slightly! I very much appreiciate this improvement!

Before: image

Now:

2 Likes

Thanks for feedback, glad to see it helped :slight_smile: I’m planning to take another look at this to see if we can make it even better without spending too much extra bandwidth.

7 Likes