I did everything to optimize networking, i used unreliable remote events and send only data i needed to replicate bullet, but it didn’t helped reduce bandwidth with 1000 bullets, which is average amount that will be replicated
Uhm yeah with 1000 bullets its obvious it will overload,
what you can try to do is to have a value on the server like local Bullets = 0
When a bullet is fired add +1 to Bullets
and put a cap on how many bullets are shown
so like
if Bullets < 60 then
-- Replicate the bullet on client
end
with this solution the visual effects are still there but it isn’t overloading big time
Problem is that i can’t simply not replicate some bullets as this may break entire gameplay, imagine player shooting from machine gun with invisible bullets, it would be terrible
EDIT: Also problem is on network itself, not on client side
The problem is that you are sending too much events to the client if your firing 1000 bullets at once
What you can do is checking if the trajectory hits a p.o.i if so just replicate a bullet hitting the person outside of the bullet cap.
So when a user misses the bullets replication is optimized and when a user hits the hit is visual
But how do i visualize a bullet? if trajectory is balistic projectile, calculating it both on server and then on client wouldn’t be that performant, right?
Bytenet for client->server->client and PartCache for bullets
thx, but i don’t like using open-source modules, as they feel limited to me, can you describe what they do? ik part cache stores instances to be reused, to reduce instance.new, but what byteNet does? some sort of buffering data?
Bytenet transfers buffers using remote events, making it waste like 100x (maybe) less traffic
Server
- Raycast to the point the user wants to fire to (this is the trajectory)
- Check if the trajectory hits a p.o.i
- If p.o.i is hit send remote to client
- If p.o.i not hit check if the max cap is not reached yet
- max cap not reached yet? then fire remote to client
When firing remote send trajectory end location with it
Client
- Receive remote fired from server
- Clone a bullet model and put parent to something in workspace
- Make the bullet go to the end point of the trajectory by using tween or something like that
As i said, this works if trajectory is linear, not balistic parabola, this is why calculating it is very costly each time
Then like the other dude said use the open-source modules as they reduce networking traffic by alot
thx for suggestion, but open-source modules are limited to me and i don’t like to use them, i prefer to seek for other solutions than relying on someone’s else job
Hello,
I recommend sticking to Roblox built-in physics engine. Here is prove it is more performant than changing CFrame.
Here is a video on how to simply achieve projectile physics:
Im not using CFrame, also roblox’s physics aren’t that good for fast moving projectiles
At the end i decided to try out parrarel luau, although i didn’t used it a lot, maybe it will help with intense ray-casting of thousands of bullets
Do you have any proof that Roblox’s physics aren’t that good for fast moving projectiles?
Indeed, i used them to make bullets for machine gun in the past, touched event didn’t worked as projectiles simply passed through very thick wall without detecting collisions, also raycasting with roblox’s physics will be worst than raycasting without it
The touched event does not fire because CanCollide could be false for the bullets you used. If CanCollide is false or a part is anchored, the touched event never fires for that object.
Using physics is in either case more performant than setting the CFrame, although I don’t know if setting the position is less performant than physics.
CanCollide was set to false, but same speed of the bullet was too high, Also i don’t set CFrame of anything, rather use pure math to calculate trajectory using this:
x = x0 + F * t + 0.5 * at^2