Hello there! I am wondering if custom physics is the best way to go for a sports game(in my case a volleyball game) because roblox’s physics is very wonky (especially network ownership). If so, how would I start? would I use lerping? would the part remain anchored all the time? Please give me some starting points.
You could completely script the movement of your ball, or you could use a mixture of scripting alongside Roblox’s body movers. You could use an Align Orientation or Angular Velocity to control the rotation of the ball and then use Align Position, Linear Velocity, Vector Force, etc. It really depends on how you want the movement of the ball to work. I would suggest experimenting with body movers so that you can see how they all work and how you might be able to use them.
Thats not the problem though, the problem is switching network ownership
From what I can tell, there isn’t much of a solution for roblox’s NetworkOwnership issues. I’ve had problems with it myself with things such as ragdolling modules. I recommend just playing around with NetworkOwnership (Changing it on the server, client, etc), and seeing what works. Roblox lacks on physics for the most part I’m afraid
Have the ball be set to the server, and the player can interact with it via remote events. This is good for anti-cheat and so it’s smooth to all players.
Well that depends on how you actually script it. If it’s anchored and your script all the physics network ownership doesn’t matter because it doesn’t apply to anchored parts. Otherwise, just set it to nil and do all the movement through the server.
Its not smooth tough, the delay is pretty bad
Then have the player replicate the ball instantly to hide the delay, and then replicate it on the server. Allow the server to have the players a small window to save the ball because of lag, even if it hits the ground on the server. Though with this solution, it will lag behind on other players and it might allow more cheats to come, but that’s not so bad. Play around with the physics to have the delay not be emphasized.
Currently, I have two balls, a server ball and a client ball. The server ball only uses server physics, and the client ball tweens between server positions, but the network ownership delay is still very visible. I might try anchoring the client ball and just making it update positions, but I’m not sure how I would make it responsive
Have the client send the server a new CFrame of the ball and replicate that for other players.
I just thought of having the server send everyone the variables for an arc, and have the server replicate it too and checking if it goes out of bounds or hits the net and such but also the clients for a smooth effect. Though it might be too hard, it will be smooth and customizable, and reliable, as it’s not random, which means it can be predicted.
By the network ownership delay, if you mean between client and server balls, it’s fine. It wont be visible to others anyways. If you mean by the delay when the client hits the ball, you should immediately start to replicate what the client thinks is going to happen. If you mean by the delay when the client hits the ball (It being frozen or still going down) try to predict the new movement on the client before replicating the new one from the server once that updates. It might also be easier with that arc solution above.
Only the server can handle the ball position unless the client is the network owner though (unless the physics are custom)
You could have the client predict the ball position, otherwise players must deal with lag and the delay for the server to update, period. There aren’t any other solutions.
Ok, so I’ve tried making the player who hit the ball hit it on their clients, but for some reason, there is delay on the client. Keep in mind that each client gets their own ball, they arent sharing one so there are no more network ownership problems. Here is a snippet of the bumping section:
local con
con =game:GetService("RunService").RenderStepped:Connect(function()
if (balldetected == true and updated == true) or bumphb.Parent == nil then
con:Disconnect()
end
for i,v in pairs(workspace:GetPartsInPart(bumphb, olp)) do
if v.Name == 'ServerBall' and v:GetAttribute("Active") then
balldetected = true
BumpInfo.DB = true
v.GameBall:SetAttribute("Update", false)
ballmod.Bump(char, v.GameBall)
packets.Bump.send({
ball = v,
pos = v:WaitForChild("GameBall").Position,
vel = v:WaitForChild("GameBall").AssemblyLinearVelocity
})
repeat
task.wait()
until v:GetAttribute("JustHit") == true
local t = 0.1
local tweeni = TweenInfo.new(t, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local goal = {Position = v.Position}
local tween = ts:Create(v.GameBall, tweeni, goal)
-- tween:Play()
v:WaitForChild("GameBall"):SetAttribute("Update", true)
updated = true
end
end
end)
task.w
it may have something to do with using renderstepped but Im not sure
Custom physics will always be better than using roblox physics in terms of performance and robustness if your use case is specialized enough. E.G physics for RTS unit movement and voxel engines