How would I handle multiple bullet trajectories?

ive been thinking about this for awhile and i thought about using a table that holds each bullet and then running through each bullet in the table every frame and then updating every trajectory. but then I also thought why not make a thread for each bullet so that it updates simultaneously?

wouldn’t i need to create a new thread every time a bullet is fired and then have it do a loop in each thread? and then close the thread after its done with it’s projectile? i want it to run each frame so wouldn’t that mean i have to do run.renderstepped on every thread? i feel like this is bad and im not sure as to what i should be doing for this issue.

please any tips or ideas on how i would manage each bullet being fired?

1 Like

How many bullets will realistically be in transition during any given frame? But yes you could create a new thread each time a new bullet/projectile is fired and then use a heartbeat loop which handles the trajectory/projection/result of each bullet, then when the projectile has reached its lifespan/hit something all you need to do is handle the result accordingly and close the created thread.

RenderStepped is client-side only and it’s typically advised to handle bullets/projectiles on the server as to mitigate the risk of potential exploits.