I plan on making a game where players would have spaceships which would be controlled via vehicle seat, its simple enough to make to go left, right, back and forwards with the VehicleSeats property, but I would also like to camera orientation of the player to be tracked to as the ships will face in the direction of the players camera.
The server cannot access the players camera, so I was thinking of maybe sending the camera.CFrame to the server every 0.5 seconds or less for the ship to then do its thing. Or is there a better alternative to this?
I believe a simpler and much more efficient way to do this would be just by sending the camera to the server, so that you can obtain the CFrame there without having to fire the server every second or so.
Depending on how big of a script your firing, it could vary, very big scripts could crash the game, while as very small scripts wouldn’t cause anything besides a little lag for lower end users.
It’s recommended player controlled objects have Network Ownership and you just locally move them since you own the physics of it.
You’ll then be able to locally check the camera CFrame and adjust it as you please on the client. This is something Roblox already does with the local player.
How often you call FireServer() is not really the issue, the issue is how much data you send over the network and how often. If you’re sending a CFrame so often you should probably look into some compression. A float is around 8 bytes I believe. If you only need to send the position and a camera angle you could drop a hefty CFrame and Vector3 down into 8 bytes alltogether(6 bytes for a compressed Vector3, 2 bytes for the angle).
All this is really only necessary once you start hitting network performance issues though. You should monitor outgoing/incoming kb/s via shift+(f5 I think?) may be shift +f3 or something else
Don’t be afraid of sending data to the server very often. I have each client send their joint data to the server every 0.3 seconds, and on top of that, I send data every time they shoot their gun (up to every 0.05 seconds). The amount of data I send is very minimal, so this will never be the bottleneck in my network.
You can optimise this by sending as little data as possible. For example, I update my characters arm joints on other clients, based on the characters look vector. Rather than sending the look vector to all other clients and having them calculate the joint angle themselves, I calculate the angle that needs to be sent on the sending client. and send that angle instead. This is a very minor decrease in data, but optimisations like that become important when you have large amounts of data to send. If you ever have crazy stuff (like needing to send a large table for a players save) you can optimise further by only sending data for specific values when those specific values change, rather than the whole thing at once (not necessary).
Bottom line: no; there is nothing wrong with frequent remote usage, but be mindful of the unnecessary data you’re sending.
For your use case, instead make sure the network ownership of the ship is assigned to the player flying it, and then you can manipulate any physics etc locally for instant feedback to that client + automatic replication
Also: these posts about “hacks” to overcome replication by “not sending data” to the server are silly. How do you think your Roblox client gets any information from the server at all? It has to be sent, creating a part or something weird like that is not reducing the data. Coming up with convoluted “solutions” to avoid using remotes is bad network design, and you’ll probably just end up sending more data than if you hadn’t tried to hack it.