Physics different for client replication?

server code:

	ball:SetNetworkOwner(plr)
			ball.CFrame = plr.Character.Beak.CFrame
	ball.AssemblyLinearVelocity = assemblyLinearVelocity

client:

	wait()
		stop = false
		local clientclone = game.Workspace[player.Name.."client"]
		clientclone.Transparency = 0
		game.Workspace.Ball.Transparency = 0.5
		clientclone.Parent = game.Workspace
		clientclone.CFrame = game.Workspace.Ball.CFrame
		clientclone.AssemblyLinearVelocity = game.Workspace.Ball.AssemblyLinearVelocity

as you can see in the video, the physics is different for some reason, even though they have the same properties??
i have no idea how i can make they behave exactly the same, please help
(half transparent ball is the actual ball, the fully visible is the client ball)

2 Likes

I don’t think you can make those 2 balls behave exactly the same, since they go through 2 seperate physics calculations. The server has a fixed physics frequency while the client’s physics depend on the device’s power

2 Likes

so how would i go about it? any good solutions?

2 Likes

What are you trying to acheive? Why do u need 2 balls

1 Like

i am trying to have smooth physics for the client, setting network ownership only works for one player, but other people get the crappy laggy trajectory, this emulates where the ball would go, and goes about it smoothly for everyone. if only it was accurate :sob:

2 Likes

Here’s my idea from 1 minute of thinking, so it’s definitely not the best idea. We can still use your approach, but after each time the ball on the server touches something, clone that ball on the client with the linear and angular velocity of the ball on the server, and repeat. I still think this is a bad idea, but it’s best I can think of for now… :confused:

Keep in mind there will still be minor inaccuracies

2 Likes

that would make the ball very “laggy” every time it touches something since it teleports one in its place
i have tried constantly making the fake ball’s velocity match the real ball’s velocity, but the problem is, the fake ball can go offcourse like it did with this, and the matching would cause the fake ball to float midair for the real ball is on the ground

another solution i tried litterally teleport the fake ball to the real one, but since its copying the real ball, its laggy and no point in adding a fake ball at all if you’re just replicating the rela one

2 Likes

I meant turning off CanTouch of the client ball or set the its collision group to which that doesn’t collide with the server ball so the touch event wont fire like crazy

2 Likes

hmm im not sure, ill have to try it out. By the way

i don’t think this is right, the server ball and the client ball both have network ownership set to the player

2 Likes

ok so i just tried it out, it was very “laggy”
my theory is the actual ball is already a bit different from the client ball, which makes the client ball teleport a noticible distance, which could be viewed as laggy

1 Like

Is that only ball Im seeing here both server and client?

1 Like

no, forgot to display the server one lol
BUT
i have made signifcant progress
it now works FULLY for one person
the other… not so much

	clientclone.CFrame = game.Workspace.Ball.CFrame
		clientclone.AssemblyLinearVelocity = game.Workspace.Ball.AssemblyLinearVelocity
	clientclone.CFrame = num
		clientclone.AssemblyLinearVelocity = cfra
	
		game:GetService("RunService").RenderStepped:Connect(function()
	
		if stop == false then

			clientclone.AssemblyLinearVelocity = game.Workspace.Ball.AssemblyLinearVelocity
		end
		end)

(gimme a sec to upload vid)

1 Like


(gotta sleep now please lmk if you have any ideas)

1 Like

I don’t have any idea currently sadly, but why do you really need use set network ownership? Can’t the ball work just fine on the server?

1 Like

don’t use physics, roblox has a official example, use math,interpolation and prediction or sth i don’t understand
Resources from the Roblox Creator Game Jam 2024 - Resources / Roblox Staff - Developer Forum | Roblox
you can edit the game here
Server Authoritative Tennis - Roblox

3 Likes

Looking at your game, it might be worth to implement your own physics with strict rules, independent on FPS.

It is not as scary as it sounds, however that will really depend on what you want to achieve.

For lossless 2D ball movement, that ignore other balls and only bounce of perfectly from static surfaces it is do-able. All you really need is to apply gravity force and calculate lossless bounces. Then you can have 100% predictable system.

On the other hand, if you want balls to bounce of each other and/or implement 3D physics, then that is A LOT of work and probably not worth it. Plus probably impossible, due to lag. For example if one player shoots their ball, at the same time as other player, it will be impossible to calculate them bouncing of of each other, if the server is not aware of their existence.

2 Likes

the ball works fine on server, except, it would be “laggy” and a bad experience for every player
doing this will ensure a smoother alternative

i would like to avoid doing anything custom as i have absolutly no experience in calculating physics.
maybe i can shift the client ball constantly to match the server?

Unfortunately the best way might be to write custom physics to simulate the ball, it might look hard first but it makes things easier on the long run. There will always be delay and some inacuracy(sorry for the bad grammar 'cause I am on mobile) between the server and the client so having custom physics that behaves the same on both is really usefull and more customizeable.

how would i write custom physics? anywhere i can start?
(sorry for extremely late response)