Physics are scuffed

My hockey puck’s physics become scuffed when multiple players play (specifically 1+ mobile player(s) and 1+ PC player(s)) (Only the mobile player’s interactions with the puck are scuffed) I’ve tried setting the puck’s Network Ownership to nil, but it makes both PC’s and Mobile’s physics scuffed, and I’ve also set it to a random player which fixes the physics for the random player but when any other players interact with the puck it is scuffed again. Also, by scuffed I mean laggy, slow, forces are weakened, and physics just don’t work as intended. The Puck also has custom physical properties and BodyForces that are added to it when players hit it.

What should I do here?

Provide a sample of the code that is not working as intended and we may be able to help.

1 Like

So there is no error in the code but rather the code doesn’t fix the physics like I want it to. I want it to make the physics of the puck run smoothly for all players but it only makes it run smoothly for the player I assign network ownership to and makes it scuffed for the rest of the players:

game.ReplicatedStorage.Player1.Changed:Connect(function()
	if script.Parent.Anchored == false then
		script.Parent:SetNetworkOwner(game.ReplicatedStorage.Player1.Value) -- This is a player
	end
end)

task.wait(0.545)
script.Parent:SetNetworkOwner(game.ReplicatedStorage.Player1.Value) -- This is a player

Set the network owner to nil, this sets it to the server and it will not be scuffed

It lags on mobile like that sill.

Mobile has some wonky stuff going on. Usually if it’s a decent phone, it should obey network ownership.

Just remember to not use a player to set it to nil, just set it when the puck is added. May be causing some of the lag

1 Like

You really shouldn’t rely on Roblox physics for things like this, unfortunately. Your best bet for a case like this is to make a puck locally for every client, and tween the pucks position whenever it’s interacted with. A method like this will take a bit of fiddling with code and might have some quirks to functionality, but it’s definitely better than relying on Roblox physics.

3 Likes

Have to agree honestly. If you wanna mess with roblox physics, its complex but usually pays off. I’d recommend you look into making custom glide physics @VolcanicsDev because if you rely on roblox, stuff always goes sideways

1 Like

Yeah, Roblox physics drive me nuts sometimes and that’s probably a better idea! Thank you guys!

set it to a random player which fixes the physics for the random player but when any other players interact with the puck it is scuffed again.

Set the network owner to the closest client in a ‘Stepped’ event loop.

local Game = game
local Players = Game:GetService("Players")
local RunService = Game:GetService("RunService")
local Puck = nil --Reference to the 'Puck' object.

local function OnStep()
	local Closest = {Player = nil, Distance = math.huge} --Decrease 'math.huge' to reduce the range.
	for _, Player in ipairs(Players:GetPlayers()) do
		local Distance = Player:DistanceFromCharacter(Puck.Position)
		if Distance == 0 or Distance > Closest.Distance then continue end
		Closest.Distance = Distance
		Closest.Player = Player
	end
	Puck:SetNetworkOwner(Closest.Player) --Set network owner to a client (or the server if no clients in range).
end

RunService.Stepped:Connect(OnStep)
2 Likes

That actually works really well! Thank you!

My only issue with this is that if the client that gets ownership is laggy, the puck begins to lag again, which is why I suggested server ownership

1 Like

You could incorporate the ‘GetNetworkPing’ method to determine if a client’s network latency is too high.
https://developer.roblox.com/en-us/api-reference/function/Player/GetNetworkPing

2 Likes

It actually still lags a bit when the player hits the puck for the first time being the new Network owner.

Just realized why it wasn’t forcing when a player hits it for the first time after another player hits hit and it had nothing to do with the NetworkOwner so thank you all for all of your help! I think it works perfectly as intended now!

1 Like