What is more resource-intensive; firing a remote event 60 times a frame or passing a table thru a remote event once a frame?

I’m trying to make a raycast-projectile system where the raycast is on the client side, and the raycast then replicates to server thru remote event, which then replicates to other clients thru remote event.
When it comes to positioning of the projectiles, I don’t know which is more resource intensive; say for example there are 60 projectiles in the air at the same time. Which is worse; firing a remote event 60 times a frame (to account for 60 projectiles/trajectories), or firing a remote event once a frame, except all of the projectile data is passed as a table (literally just the position and one other parameter or smth)?
If you need more information just LMK, I’m still on the fence about this.

2 Likes

In this case, firing one remote event per frame is by far the better option. However, even one event per frame makes for a ludicrous workload. In fact, roblox will probably block you from firing and receiving this many remote events.

Why can’t you do the Raycasting on the Server, so that you don’t need SO many remote events. Even if you found a way for this to not break your game, it would be extremely recourse consuming, and would kill performance.

If there is another option, do use it, as this is an extremely bad practice that is very impractical.

3 Likes

From my experience I don’t see an FPS drop unless I am rendering stuff or instancing parts.

2 Likes

like what @ExcessEnergy said, it would lag. A thing I want to mention is that since it is client side, an exploiter can essentially change their Ray so it hits whatever target they want without any skill.

I think it should be entirely server side, it shouldn’t cause that much lag.

IF lag does becomes a problem maybe re-use rays.
What I mean by “re-use” rays is that a ray from one bullet can be exactly the same as the one before or after it, since it they were fired in the same physics simulation update. So maybe assign a ray per simulation update(s) instead of assigning each bullet a ray.

1 Like

I run my rays on a Heartbeat loop, meaning that the rays fire every frame (if not, a decent amount of times per second). I do this to simulate bullet drop; I string together multiple small rays to simulate the trajectory of a projectile interacting with gravity.
I actually do the raycasting on the server, but after discovering that raycasting multiple projectiles at the same time causes heartbeat drops, or encountering physics-heavy games with horrible heartbeat delta times, I’m looking for another answer, which is why I’m investigating client-server-client raycasting.
As for preventing remote logging, I’m quite aware that exploiters can manipulate their rays, so I’m working on creating sanity checks as well.
But anyway, I’m still looking for alternatives. I’m investigating into the remote-event-firing-once-per-frame-but-with-tables thing. Thanks anyway, guys!

1 Like

It really depend what you’re sending. The most efficient solution in terms of network usage would be to send 1 compact string at the end of the frame. string.pack is a great way to do this easily.

6 Likes

Hey, this sounds like a nice idea but I currently have no clue what string.pack means. I tried looking it up but to no avail, apparently it has something to do with tables. What does it do?

string.pack is a new thing for compressing data.

2 Likes

Hi Tomarty,
So I’m trying out what you suggested me; using string.pack to pack all of the data into one string and firing it every frame. I literally have no idea how to do this; in terms of client-server-client replication, one client can send data to the server and then the server replicates it to all of the clients, but when multiple clients send stuff to the server I don’t know the “time increment” per say, for the server to fire events back to the clients. How would I do this? Is there any other way? (currently I just have clients shoot data thru string.pack and the server back to client with the same way)