Best way to optimise ball physics on the server?

What I’m doing
I am making a volleyball game which requires ball physics to be ran on the server. I would like as little lag as possible to keep the balls smooth and playable. There will be multiple balls which rely on physics.

I’m under the understanding that the balls network ownership will need to be on the server to avoid jittering. But feel free to correct me on this if there is a better way to do it.

My main question
Are there any tips for optimising performance for this kind of thing?

I’m not sure of what I should avoid or the best practices I should be doing.

1 Like

Ideas I have found so far?
I’m going to research on the devforum and document my findings. However, please know that I do not know if these work or are the correct answer. Researching each of these before implementing them is important, especially since everyone’s game is different.

  • Ball pooling system (not sure how expensive creating a new object is)
  • Having the outer map (not the actual court) be visible only to the client so there is less parts
  • Parallel Luau? (I don’t have the best understanding of this though)
  • Interpolation Throttling? I’m not sure if this affects server owned physics parts
  • Using unions appropriately
  • Disablling climbing, swimming, and seated humanoid states (need to check if this actually helps performance)
  • Different quality levels for different devices (mobile - no shadows etc)
  • < 20 players as humanoids are expensive
  • Can touch set to false on parts that don’t need to trigger touched events.
  • Aiming to send less than 25kb/s of data - network optimisation guide (unsure of credibility)
  • Streaming enabled? Might not be necessary since my map isn’t going to be huge and might affect physics (I don’t know)
  • LOD but it doesn’t apply to me since my maps small
  • General tips on memory
  • Clone ball on client and have it match server ball with lag compensation
  • R6 characters due to less joints (my game is R6 so I have no need to bother testing this)
3 Likes

Putting the outer map on the client should help if it’s a big map, but if it isn’t that large (a couple thousand Parts without Transparency and Reflectance set to 0 it shouldn’t make a huge difference.

How many Unions are you talking about? If the Unions are simple shapes then just use Parts. If they are complex then consider converting the Unions to Meshes with 3D editing software so you can clean up all the extra tris a Union creates. Some Unions I’ve created had double the tris that the exact same MeshPart would have.

2 Likes

I haven’t really gotten to map creation yet but I don’t think it would ever get bigger than 3 courts. I’m probably going to aim for no unions, and if I need more complex shapes then using Blender like you suggested. I’ll also probably only render the base court on the server (floor, net). Things like the gymnasium, spectators, etc can be done on the client.

2 Likes

An example of one court. I will plan for the “map” to be clientside leaving just the base court and net for the ball to interact with.

The court on the server will probably look something similar to this leaving the details up to the client.
Anything past the walls will be client only (my “background” maps)
I’m assuming decals will handle better on the client if that is possible.

This might not be necessary since the court itself isn’t very many parts. But if I do add a gymnasium or spectators then they will be handled locally.

1 Like

A sphere bouncing around is a very simple case for the physics engine to handle. The volleyball courts are also very simple. You shouldn’t need to perform any heavy optimizations for physics to work smoothly. I would not worry about trying to only load certain parts on the client vs server etc - especially since they are all anchored. Majority of the things on your list of optimizations will not help, and even pointlesslty detract from the fidelity of your experience.

I reccommend you leave things as they are, develop the game, then come back and optimize if you notice any performance issues.

The only thing I think you’ll run into is network latency causing gameplay to feel less smooth. But nothing on your list of optimizations can improve this - its entirely dependent on a client’s network speed/ping. You can compensate for this with animations/fx, or trying some system where the client will sometimes simulate the ball themselves for smooth gameplay.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.