My current project requires me to handle a large amount of NPCs. After doing some research I came to the conclusion that the best way to go about this (in my opinion) would be:
Have a single part represent the NPC on the server
Have the client render the NPC’s model and make it follow the server-side part
Ditch Roblox’s Humanoid object
First of all, if you think that the methods above are inefficient or if there are betters way to do it, let me know. I would like to hear your thoughts.
Second, ditching Roblox’s Humanoid object means that I need to create my own MoveTo and Jump functions. I am not quite sure how to go about this yet. What would be a good way to handle this?
For MoveTo, some of the methods you could use are iterating towards a specific location on a server, lets say you start at A and end at B, you know the NPCs walkspeed, and after some quick calculations with the distance between A and B, you can gradually iterate between these positions using chunky CFrame updates.
On the client, you can have the NPC be rendered, and lerp its CFrame towards its “position”. This is essentially creating a poor-man’s MoveTo function, as the NPC on the client won’t immediately snap to its location on the server, but move towards a position the server has in store for it. I’m sure there are better methods, but this should work in theory.
Handling jumps, you’d have to code your own. One method is the following;
When jumping, assign the NPC movement code a upwards velocity.
Every frame you’re in the air should look like; Velocity = Velocity + (-Gravity * delta)
This means you’ll fall at a steady, expected rate.
Not sure if this’ll help, but its what I’m doing/thinking of using!