Enemy System Optimization

For the server: is it necessary to check the position progress every 1/60th second?

If they move between waypoints in straight lines, it probably isn’t…

1 Like

So no Y pos and I rotation is necessary on every axis but the Y, as I plan to implement bezier curves/ smooth turning from 1 waypoint to the other soon.

I agree, my method was flawed originally and Jqck showed me how to reduce updating and checking progress every 1/60th second

Alright so not much can be sacrificed in that aspect

Cool, though I warn you, this is gonna be pretty in-depth.

So first of all we need to know how much bytes are send over the remote for each value type, and FYI 1 byte = 8 bits. Each time you fire a remote there is a ~9 byte overhead which is fixed and can’t be changed. However the rest depends on how you send your data. For simplicity, here is a table containing the byte overhead for each datatype.

string: length + 2 bytes

boolean: 2 bytes
number: 9 bytes (IEEE-754 signed doubles)

table: 2 bytes

EnumItem: 4 bytes

Instance: 4 bytes

Vector3: 13 bytes

CFrame (axis-aligned): 14 bytes
CFrame (random rotation, non-axis aligned): 20 bytes

Now if we were to send a CFrame every 1/10th of a second, best case it would take 14 bytes and worse case 20 bytes per cycle. However if you look at the table, you will notice that a string has a relatively dynamic and small byte overhead. So if we were somehow to encode our CFrame to a string, say the position data into 3 characters and rotation data into 3 character and combine them together to a string of length 6, then the total byte overhead will be 6 + 2 = 8 bytes which is much better than either 14 or 20 bytes. And ofc, we can go about encoding the data manually, but recently I found a module named Squash which eases this process.

So with that, while firing the remote just do Squash.CFrame.ser(cframe: CFrame) → string and when receiving do Squash.CFrame.des(cframe: string) → CFrame.

1 Like

I get what you’re kind of saying here, we’re just doing some bit compression so the sent and the recv isn’t so high. So when I receive the CFrame on the client would I just PivotTo that? or would I lerp to it?

Recommendation: Use Parallel Luau

It can help improve Performance, and can help with faster Calculations by allowing multithreading to make your game faster.

1 Like