Hi! I’m making a game with 5 dummies in 10 different stages and when you get close, a letter e is gonna appear. So how do you think the performance will be?
Script performance:
Hi! I’m making a game with 5 dummies in 10 different stages and when you get close, a letter e is gonna appear. So how do you think the performance will be?
I would not recommend using RenderStepped for this. I bet you’d see a noticeable difference in performance if you used a while loop that ran every tenth of a second, or however fast you need it to run.
RenderStepped is generally only a good idea for utilizing the camera. Hope this helps!
So your algorithm can be easily optimized by instead of looping through every stage and then each dummy. Just having a check that only occurs every few seconds to tell which stage it is in. That would reduce your complexity from O(n^2) to O(n) for the majority of cases. Worst case scenario of O(2n)
Second of all RenderStepped seems like a super convenient way to make a loop run really fast, in reality 90% of the time it is a waste of precious computing power. In this example you check the position of the player relative to all the dummies and the stages every 1/60 of a second. Moving at 16 studs/per second a player can only move .2 studs. If you just use a while loop with a wait(.2)
that will be much more performative and you will not be able to notice a difference.