Which Loop should I Use to make accurate Projectiles? (About 50 Max at a time)

I’m making a 2d boss fight for my friend and having problems with Projectiles/moving parts, in general it “works” but feels funky and when lots of projectiles are on screen It starts to lag (In which case the projectiles all start to lose velocity)



This is the main code where I handle the projectile motion, it looks ok when using client side tweening but the real problem is the lag, how should I fix this/which loop should I use in this situation?
(About loops I’m reffering to things like “While loops” or Renderstep.Hearthbeat, that stuff)

If you wish to make accurate projectiles I recommend delta Time method where you do:
get current time
get end time
create a while loop that lasts until end time
check with raycast
make sure it runs each hearbeat (postSimulation) so just use task.wait()
depending on deltaTime calculate rest of the things you need

1 Like

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