People always suggest not to put too many things in Tick function. I wonder whether there’s a limit of the things it could execute while not affecting performance, because so far all the projects I made, no matter how many things I put in it, I don’t see that the performance is clearly affected . I think this should relate to the configuration of the PCs, right?
The most common (minimum) frame rate you aim for is 60Hz.
This means when your computation every tick (1 tick = 1 frame) exceeds 1/60s = 16.66666ms you can not reach 60Hz frame rate. This is caused because the engine has to wait to complete the tick computation before it can start the next frame.
How many operations you can use until they need 16ms time is machine dependent as you already pointed out.
And all the people always suggest to not use the tick function to heavily for a good reason! When using it, it can lead to heavy decrease of frame rate. This can simple be avoided by using timers. Functions called by timers should be running in its own thread (i don’t have confirmation of this) and therefore never interfere with the framerate even when doing heavy computation.
Thank you fabianu! OK, now I see. So the lag during the game running is due to the fact that we put too much things in tick function and it couldn’t finish within 16.66666ms, and therefore it needs more time to compute, right? At least this makes sense to me