Hello. I am currently having issues with making a smooth blocking system for my volleyball game. For context, in my game, there is a server ball and a client ball. The server ball is mainly for sanity checks, but the client ball is used to make the game visually pleasing. The system has been working fine so far, except for blocking. If I replicate the block to all clients from the server, it will look really bad on the other clients. The current system I have now is that every client detects blocking separately by checking if the player is in the air. The problem is that there’s no way to smoothly sync every client ball. For example, one client could make the ball go over the net, but on another client the ball could hit the net. If I try to sync them with the server, it would look bad because they would teleport to the server ball’s position, and I have no idea how to fix this. Any help is appeciated and thank you!
What if you used lerping to smoothly move the ball on the client to the server position?
You could maybe have the Ball on the server be just a CFrame value that you can access on the client and simply lerp to that point
Sorry if i understood sum wrong here i js got confused by your post
Thanks for the reply. I am already using keeping to move the ball, and even though storing a cframe value in the server ball isn’t a bad idea, there will be delay when I update the cframe value, meaning the issue will remain.
Im not sure how the math behind the ball functions but could you do something similiar to what roblox does with player movement?
Idea being to store something like a MoveDirection property on the server and whenever it updates send it to the client and then on the clients simply use that MoveDirection to calculate where the ball should be positioned
(im sorry if this sounds dumb im half asleep )
I’m pretty sure that would have the same exact issue because it’s the same concept as storing a cframe in the server ball
In such a case, it’s just better to create a basic physics system rather than relying on Roblox replication.
For any moving projectiles on a set path (e.g. linear or bezier), I set up two attachments: one server-sided attachment with a CollectionService
tag, and a client-sided attachment that follows that. On the client, you will have the ball part/mesh, which uses AlignOrientation
and AlignPosition
for alignment to the client-sided attachment.
The server-sided attachment can be moved wherever, and the client-sided one (and thus the visual ball), follows it. To do this, use springs; always have the spring target be the CFrame
of the server-sided attachment, and every frame, move the client-sided attachment to the spring’s target.
This does a few things:
- Completely optimizes your performance on both the server and client by preventing geometry calculations
- Smooths out the movement completely
- Still allows for server-sided verification
- Prevents collision or physics issues
Hope this helps!
Dont springs only work on unanchored parts though? I’m using a custom physics system that keeps both balls anchored
I always expect client physics data to be different for each client. Here’s my suggestion. Reference the serversided part and interpolate the client ball inside the client.
If the serversided ball is the most reliable thing, you can use UnrealiableRemoteEvents to constantly fire the Vector3 position of the ball to each client on important avenues, and use either position constraints or your own interpolation to match the ball with the incoming Vector3 inside per client.
If I am correct, this will work if both balls aren’t the same instance.
The problem is that when a player blocks, there is a delay before the server receives the information. How would I handle this delay so that the visual ball isn’t delayed too but it is also in sync?
Well, having a delay goes against the idea of efficiency doesn’t it?
You’ll have to send prerequisite data which will replicate to all other clients to sync.
Oh wait nvm I think I thought of the solution. Basically, the server detects the block by checking if the player is in the air, then it fires to all clients, so instead of client>server>client it’s just server>client.
I’ll test this out once I can and update
Spring as in the interpolation method, not the spring physics constraint.
This method works fine, but the problem is that it is extremely unoptomized because i am using a heartbeat loop on the server to detect the ball and then another heartbeat on top to move the ball. Is there any way to make this more optimized?
I think if it works smoothly, you’ll be fine. Also I didn’t exactly understand your solution, wouldn’t player still need to press a button to block the ball? So it’d still be client>server>client (unless I’m missing a point here)
no because in my game, instead of pressing midair to block, you switch modes while grounded and you cant switch modes while in midair, meaning you can just fetch their mode and if they are in the air from the server.
Use RunService PreAnimation, and if you can, run it specifically in a reduced tickrate or so. Somewhere below 60.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.