I’ve done an script that controls every NPC already (well, it has a few flaws, but i’ll most likely fix them), i’ve seen people claim that generally, it’s better for performance to have a “Master Script” which controls every NPC, so my question is:
Is this true? is there a noticeable difference? does it truly help performance, or i shouldn’t really worry about it.
Also, i’d like if someone could help understand something, so right now what i’m doing in my script is to check magnitude between the NPC and the Target to deal damage, however, since i want the damage not to be dealt each second, should i have a coroutine which handles it? I’m not sure about that, so if someone could point me into the right direction it’d be pretty nice, thanks!
As well as that, if you’re using humanoids, to further increase performance (humanoids eat server memory faster than chrome eats ram) you should disable any states you won’t need, such as climbing or swimming.
I think the main reason why it’s “better for performance” is that you can combine things - when you’re controlling them each individually, you’ll probably need to recalculate things that are common between them and those calculations take time. If you, for example, want to send every NPC to its closest player, then there’s algorithms which can more efficiently do that than just having to perform the same series of calculations over and over for every NPC that you have.
I think it would come down to the algorithms and stuff, though. If you’re doing it inefficiently, you won’t notice much difference. So you need to know about how you can do that & whatnot, which can get complicated.
In short - I would suggest combining it, especially if you’re going to have a lot of NPCs in your game. But the difference may be negligible depending on how you go about it.