CFrame + NetworkOwner = Server breaks physics on models

I’ve been noticing this issue for several months but have ignored it while working on more important things. When I clone models on the server and then set the CFrame of the primary part, the object will hover over the ground instead of making contact with it. While hovering it will rotate for a period of time.

A model consisting of a single part, will simply fall through the baseplate even though CanCollide is true. From reading other threads I’ve also tried setting a small velocity on the primary part in case the physics engine stopped processing the part due to not having a velocity set. I’ve also tried giving the primary part a Touched handler.

If the Network Owner of the primary part is set to the player, or if it is set to auto and the object is within the player’s SimulationRadius, then the object will behave as expected. Even when the Network Owner is set to the server if the player is positioned directly next to the model, it will fall to the ground as if Network Ownership were transferred to the player. If the player is then moved just a few studs away from the model, it pops back up into the air.

With network ownership set to the server, if I do not CFrame the model’s primary part, the model will behave as expected and fall to the ground when cloned in.

I’ve attached a repro place demonstrating everything I’ve mentioned.

Any ideas on what’s going on?

Original
FloatingModelTest.rbxl (20.7 KB)

Updated
FloatingModelTest.rbxl Update 1 (21.5 KB)
Changes:

  • Welds Enabled = false by default
  • BillboardGui above each model explaining the differences

Even with the welds disabled until after cloning, I didn’t notice much difference. The CFrame + Owner: Server model will drop to the ground when the player makes contact but after walking away about 10 studs, it pops back into the air.

So I messed around a bit in the repro place and I found that when I set the WeldConstraints initially to disabled, and then enable them after the model is cloned, it seems to be working as expected. Albeit I need to be near the model before it actually drops to the ground but I can say with confidence something is wrong with the consistency/replication of WeldConstraints when cloned.

Hope this discovery may help!

Even with the welds disabled until after cloning, I didn’t notice much difference. The CFrame + Owner: Server model will drop to the ground when the player makes contact but after walking away about 10 studs, it pops back into the air.

I have no idea what is going on, though I tried your example and see the problem.

Perhaps a model’s primary-part isn’t supposed to be CFrame’d?

I slightly changed your code where it sets the position, so it uses the TranslateBy method, and by doing so, it looks like the models seems to “work better” - i.e. falls to the ground.

	if (self.Position ~= nil) then
		local extentsSize = self.Model:GetExtentsSize()
		self.Model:TranslateBy(self.Position + Vector3.new(0,extentsSize.Y * 0.5,0))
	end

Addendum
Actually it seems to be the CFrame.fromMatrix() that “does odd stuff”, because using the following code, produces expected results:

	if (self.Position ~= nil) then
		local extentsSize = self.Model:GetExtentsSize()
		local currentCFrame = self.Model:GetPrimaryPartCFrame()
		self.Model:SetPrimaryPartCFrame(currentCFrame + self.Position + Vector3.new(0,extentsSize.Y * 0.5,0))
	end

Been meaning to come back and update this. @Decker004, your “addendum” to your last post lead me to the answer.

It turns out that it was the way I was using CFrame.fromMatrix() that was causing the problem.
The documentation says:

I was passing an apparently wrong value in as the vZ parameter. Since the documentation says it would be calculated if excluded, I decided to try that. Worked as expected.

So thank you very much for that lead!

2 Likes