Performance issues, when tweening large amounts of projectiles

Hello, I recently made a projectile system, if used on the server side, will update a projectiles position 24x every second. this has the consequence of appearing laggy, on the clients screen. so I decided to tween the projectile to the next position. When a large quantity of projectiles are present, The CPU usage spikes, and the game becomes unplayable. I decided to remove the tween, but I once again have the projectiles appearing as laggy.

I wish to achieve a stable level of optimization, While maintaining good visuals on the projectiles.

Thank you for reading, input is appreciated.

2 Likes

Why not tween the projectiles on the client?

Are you handling the movement of the projectiles on the server? Regardless of tween or not.

OP is updating it on the server.

Projectiles are updated on the server, but tweened on client, as stated before this has a heavy cost on the cpu usage.

Only projectiles fired from servided entities, players handle the projectiles on their own client

You could try using :lerp() instead of tweening, I am not sure what could be causing the high CPU usage though.

I see, why not try updating them less often? Also, why not try not tweening projectiles that are further away/not in the players’ view?

Calculating if a projectile is within the characters view is taxxing, but would save some usage.

Wouldn’t fix the issue if it’s in your face.

i can try lerp, but i believe it will have similar cpu usage as tween, but slightly less

You aren’t wrong but I don’t see any other answer except for manually moving it on the client by not using tweens.

What about the BulkMoveTo function? It seems to be designed specifically for moving tons of parts in the most efficient way possible.

Marked as solution for now, unless someone has an even greater idea

1 Like

Are your projectiles relatively fast and not long lasting? You should take a look into caching modules like PartCache because constantly instancing or cloning new projectiles, only to destroy them a second later can be expensive for the CPU when mixed with tweening aswell. You should implement some sort of caching aswell as what the reply above me suggested, as constantly creating new bullets can also be having a large impact on how performant your projectiles are. You should also try to switch everything visual in your game to solely be handled on the client as letting the server handle it might negatively impact your game’s network bandwidth usage.

Everything visual is handled on the client, but projectiles fired from server sided entities are handled on the server, for anti cheat purposes. the actual tracer and part are handled on the client. since using a cframe value saves performance over a part. I have already made a caching module, but this impacted performance more minimally than I expected. I also believe that using remotes every frame to retrieve the projectiles cframe, is very suboptimal, since Roblox sends a single package with all updated data to the client anyways.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.