How do I optimize server side NPC movement for an RPG (Massive amount of enemies)

  1. What do you want to achieve?
    I am creating an enemy AI system, which has a simple command: attack if near, else follow the player, via pathfind or direct follow.
    I am trying to prevent lag in the server already, removing unnecessary things for the server to handle, like the npc model and animation.

  2. What is the issue?
    I don’t know what approach to use in order to move the enemy in the server side. Is humanoid:MoveTo() bad in this case?
    How do I check if an NPC movement is possible elsewhere? Raycasts seem like it will allow possible noclips from the NPCs, and Shapecast looks too expensive to be constantly used.
    Should I use CFrame? Won’t there be a possible noclip from the enemies?
    What about bodymovers? Won’t they lag as much as humanoids?

1 Like

Atrazine made a post about how he handled that in his game. It’s a really good resource

1 Like

AnimationControllers and models run on the client, server used just for bare raw data, I suppose using cframe lerping + raycasts is the way to go uf you are looking to accomplish something like this:

1 Like

Okay, that seems to work great! Remade some of the code for this and the script Activity/Rate seems to have went from 1.4%/30.0s to .2*/6.0s. Probably needs more optimizations, but it’s already a great step.