I’m terrible at describing things through titles. So let me explain. I have a system for a competitive shooter I’m working on, in which the player’s hip joint bends to point at the mouse’s hit position. Because the hip bends, the location of the gun’s muzzle also moves. These changes are local, however, which means that what the player sees as a shot is unaligned with what the server sees as a shot.
I’ve considered the possibility of sending the server a remote event containing the player’s mouse position, so it can be updated on the server. Sending a remote event every frame, however, is costly.
(Please note that, as the effect is local, it is not necessary for gameplay. It is, however, way more attractive visually, and I’d like to avoid removing it any way I can.)
Should I approach this differently? Are there any optimization tips? Or should I just scrap the effect?
Correct me if I’m wrong, but I believe the player has the network ownership of the players character, so you can do whatever you want in the players character in a local script, it’ll replicate to the server.
@syntaqs That’s true but that only applies to physics changes which is related to network ownership. For joints like Motor6D C0 and C1 animations the properties do not replicate.
For an optimization tip for @McBubskini you can reduce the number on remotes by sending every few seconds.
To interpolate you can :Tween or :Lerp to the next CFrame so it still looks smooth even if it isn’t getting the data every frame.
I found every 0.2 seconds is good enough while still looking smooth
Other optimization tip is to send a Vector3int16 data type instead as it has less numbers
That tip is from the post below, lots of other optimization tip to reduce data usage check it out it’s great
You could optimize by reducing the frequency at which the server is fired, i.e; from once per frame to once every other frame or once every ten frames etc. To prevent choppiness, transition gaps could be filled by Tweening/Lerping on the server.