In my hockey game, when you shoot the puck at the goalie, the game is supposed to give network ownership of the puck to the goalie so that the puck does not go through the goalie. This has been working completely fine and I have not altered this in any way. Suddenly, I was receiving complaints about the puck freezing in front of the goalie and overall just being weird. Basically, what happens is, if you were to shoot the puck at the goalie, it would freeze as soon as it gets near the goalie, and it would stay stuck there. The weird part about this is that the goalie sees the puck at a different place in the ice while all other players still see the puck in front of the net. It should also be noted that changing goalies will fix the issue, it seems to happen when the same player stays goalie for a long time. Judging from the fact that this did not start until recently, it could be related to the recent physics update.
A community tournament is starting on June 1st for my game, so I need to fix this as soon as possible. Any ideas on how I can start to approach a fix towards this?
Why does the goalie need network ownership of the puck? Also, how would setting network ownership prevent it from going through the goalie?
I’m not entirely sure on this, but it may be an anomaly with physics, where the new owner doesn’t have the prior momentum of the puck, so it assumes it was still.
Try recording the momentum and direction before setting network ownership, and applying that using vector force, for example, onto the puck.
If the goalie has network ownership of the puck then the puck won’t pass through due to latency, and the goalie will also have no network latency when it is most important.
A temporary fix could be transmitting CFrames of the puck from the goalie to the other clients (through the server using a RemoteFunction), and then lerping the puck towards those CFrames.
Re-read your code to check if any events occur when a player is a goalie for a long time, this may help you to find the cause of the problem. Printing statements during events can help, too.
Or, this could be a physics bug. Anyways, try my “solution” and see how that goes.
This freezing is due to the fact that changing network ownership between players/the server take some time, and therefore there is some physics lag.
This is talked about here Network Ownership | Documentation - Roblox Creator Hub - you can see a similar issue in the Problem of Example 1: Projectiles
I would recommend that you keep the Network Owner as the server at all times, and don’t change it, otherwise you will see this jittery behaviour. Unfortunately this will lead to some lag shown
A way to minimise the lag shown by the player is to only transmit the data of the direction the puck is moving, and the speed it is moving at through a RemoteEvent to all clients and have them move the puck themselves (As recommended above by UltimateRaheem)