Compressing CFrame Values

So I’m doing a custom character system where I’m sending CFrame values over the network for replication. However, since I am doing this repeatedly, it can get very costly. I’m looking for the best way with examples on how to compress CFrame values with string.pack and string.unpack.

Where are you sending the values? Across the Server-Client boundary? Or to roblox?

Across server. From client to server to other clients

1 Like

I don’t think it would be too costly. There are limits when communicating to Roblox’s websites, etc. (i believe) but as long as you don’t fire like 1000 remote events at a time, I think you’re good

Read more here:

(I believe you are sending data via remotes)

Also, couldn’t you handle everything or most things on the server? For example, a player requests to change into a character and the server can handle most, if not all, of it: get character, replace player with character, etc.

You completely missed my point. I don’t have an issue with sending data over remote events. I want to know how to compress it. Please stop replying to this thread. Thank you.

my bad

Why do you need to compress it though? Sending a little more over the network surely can’t be more costly than a full compression algorithm, unless you’re trying to store data. How much of this data are you expecting to be sending?

Also don’t expect to use conventional algorithms for this. If you understand file compression, you’ll know that’s a bad idea. I just zipped a CFrame and the size quadrupled after compression. If for some reason you really want to go through with this, your only real option is to write your own compression algorithm specific for CFrames that isn’t resource intensive and might have a hope of saving space. Believe me when I say it’s not worth it though. You can’t save much space in a CFrame without taking up more space than you started with.

Edit: also when Roblox serializes it, they’re not using strings. Using strings will cause it to take up either more data or more processing power, take your pick.

2 Likes

I’m not storing the data anywhere. I just need to get it to the other clients across the boundary. It’s proven that string.pack and string.unpack reduces data usage by using a reduced number of bytes. Only issue is accuracy lost to a certain extent, which I can tolerate.

You can cut the size in half by reducing the precision, is that what you mean? That’s not compression then, that’s just removing data.
https://www.lua.org/manual/5.3/manual.html#6.4.2

Yes, this is what I mean. Unless there is another way to do it.