I’m attempting to make a touch football system with smooth physics like this one. I’ve tried several different methods like Network Ownership and other things, but I can’t get it to be smooth like in the game below. I think that this game uses some sort of way to simulate the ball’s physics on the client for smoothness and I’m wondering how to do this?
If you simulate the ball physics on the client, nobody else will be able to see it, I think it can be done with linear Velocity on the ball.
Based on the way that the ball moves when touched, I believe this is how it operates.
So, I believe when the ball is touched they have some sort of system like this:
-- *SERVER*
local Ball : BasePart = workspace.SoccerBall
local SimulatePhysics : RemoteEvent = game.ReplicatedStorage.SimulatePhysics
-- If the ball is touched by a player, then they will operate its physics
Ball.Touched:Connect(function(hit : BasePart)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
Ball:SetNetworkOwner(player)
SimulatePhysics:FireClient(player)
end
end)
Basically the server will check if the ball has been touched by a player, and if so, will tell that player to calculate the physics.
Now all the client has to do is calculate the physics.
-- CLIENT
local Ball : BasePart = workspace.SoccerBall
local SimulatePhysics : RemoteEvent = game.ReplicatedStorage.SimulatePhysics
SimulatePhysics.OnClientEvent:Connect(function()
local force = Vector3.new(0,10,20) -- Just an example
Ball:ApplyImpulse(force * Ball.AssemblyMass)
end)
Obviously this is a simplified structure, but the core remains the same.
If you worrying about the physics changes not replicating, it will replicate because the player has network ownership over it.
Simulate ball physics for each client
Okay, but what’s the difference between just doing the physics part on the server with network ownership?
The difference is the strain on the server and delays. Doing it on the client is also way smoother cz the client isn’t doing as much stuff as the server
Okay, So I sould just handle all the forces stuff on the client then. Is there any way to prevent exploiters from abusing this? For example changing the ball’s force to 9000000 or something
Once you give a player network ownership its hard to prevent things like this so you’ll have trust the client for the first time. You should NEVER trust the client but the number of exploiters has gone down meaning its safer to do so. I think for a game like touch football players wouldn’t really want to exploit it because they don’t gain much from it.
Okay thank you
Sure you can, but it won’t be consistent.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.