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.
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)
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.
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.
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.
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.