How do Dungeon Quest handle much NPCs and how do they do it?
I tried to make multiple enemy NPCs but they lag the game once all of them starts moving, I also made it so they only move when they have lower hp than max hp but it still lags when all enemy NPCs started attacking me, I can’t find any other solution for this, I need help.
First off, there are tons of posts about reducing lag with npcs or humanoid characters. Please make use of the search bar next time.
Secondly, the best way to do this is remove states that the npcs does not use.
For example, the Climbing state ray casts every frame for every npc, and most npcs never even climb. To disable states, you can do the following:
To reduce lag further, you can have the npcs simply be a invisible root part on the server then add then through the client (this allows you to render only a certain amount at a time, great for lag reduction)
I’m frankly not going to be surprised if the source of lag comes from you using legacy NPC follow movement code which iterates through the entire workspace. That being said, I can only assume this is the case because you haven’t provided any code and instead asked how another developer handles their NPCs, which none of us would realistically know how.
To reduce lags, you can just use loops of Humanoid:MoveTo() following the player near it and then make it so they attack once it’s inside a certain magnitude, and damage people.
This way, it’s less laggy than having a Touched event.