Hello, I recently noticed that when a touched event is triggered a lot of times, it can cause latency for the client. This problem was solved by putting the content that was in the function in a loop.
My question is: Do all functions affect player performance in the same way, or will some functions consume less memory/performance than others?
The performance impact of a function depends on several factors, such as the complexity of the function, the frequency with which it is called, and the amount of resources it consumes.
For example, simple functions that perform basic arithmetic operations or update a single value may have a negligible impact on player performance. On the other hand, complex functions that involve a large number of operations or require significant computation may have a noticeable impact on performance.
Thanks for the answer, unfortunately the gpt answer tells us that it depends on the actions that the function will perform (arithmetic etc), but I’m trying to find out if two different functions (no matter what is in the function) can have a different impact.
I don’t quite understand the question, but events allow you to run code only once something happens. This is really good for things you expect delays in between. Even firing it a few times per frame shouldn’t be an issue. The problem comes if you end up making many attachments by connecting multiple times. Generally I think that though a loop would technically be slightly faster, it shouldn’t have been enough to be human perceivable. I would imagine the original code accidentally connected an event for every item multiple times, though without extra context this isn’t quite possible to state absolutely.
Well, my question is whether all functions have the same impact on performance, without considerating what’s inside the function. For exemple : I’ve noticed that a touched event triggered many times (without executing anything in the function) will cause a lot of latency for the client (unnoticeable on a good computer).
Whereas a loop that acts as a touched event (getpartinbound, magnitude, raycast…), which is executed many more times than the touched event, will paradoxaly cause less lag (much much less). I’m wondering if this is specific to a touched event, or if all functions will have the same impact on performance
So now for a touched event i use for exmeple getpartinbound in a loop that i do in this union, welded to the character (r6 game) . And for moving part using prismatic i will detect when change direction with magnitude in a loop (while i used to work with touched event until i find that it’s highly unoptimized). So i use a single loop of around 300 lines that handle almost the whole game