Best way to render ball locally given position from server?

I’m trying to render a ball locally given position and velocity values that are updated server side (I want a server authoritative ball that lags as little as possible, so Roblox physics is to my experience insufficient). Currently I have these values being updated on .Heartbeat from the server, but locally this isn’t fast enough to make the ball move smoothly.

Currently I have a pretty janky setup for local rendering - I have a ball’s CFrame updating with the renderstep:

ball.CFrame = ball.CFrame:lerp(CFrame.new(position.Value + velocity.Value * 0.05), dt / 0.05)

where dt is the renderstep time. This is pretty bad - all it does is make the ball approach a future position (and it slows down while doing so!).

So, any ideas for a better way to render the ball locally?

5 Likes

Hi, you can use tween service. The movements will be fluid. But I didn’t understand a part. Do you want the ball move only at the client side or the customer to make it move for server?

I want the server to move the ball for all clients.

TweenService is impractical (as far as I know) since the trajectory of the ball is parabolic (this is a physics based game). So unless creating a tween on renderstep is somehow a good idea I don’t think this is a great solution.

Ok, parabolic trajectory is hard with tween service. You want to calculate physics client side or server side? Or both?

Purely server side, since I want all clients to sync to the server and the server to be authoritative.
I have however considered calculating some of the physics clientside, though apparently this is laggy according to people who have tested my game when I did that (?). I might try it again though.

1 Like

You can set networkowner to a client if you want calcul physics by a client. If the client is networkowner of a part, all client can see part move. And you can use Heartbeat event RunService | Documentation - Roblox Creator Hub to move the part.

1 Like