Hello, recently I worked on an NPC system for a project I am working on and would like to release it for use and what-not.
https://www.roblox.com/games/7830587212/350-NPCs-Test
In order to make an NPC you need to tag a part with "NPC"
I recommend getting https://www.roblox.com/library/948084095/Tag-Editor
Information
Manages NPC position on the server and completely renders the NPC on the client. There is minimal things happening on the server to keep as low network latency as possible.
With 352 NPCs -
A total of 4 tags are used for each NPC.
- NPC (Server/Client)
- Statesystem (Server)
- Render (Client)
- Animate (Client)
About
I previously have never attempted to create a good amount of NPCs while keeping low network latency and not killing the player’s computer so I figured it would be a fun task. The project file you see is the result of probably a week of on and off research and a lot of trial and error.
Throughout my research there was a huge lack of open-source material in order to produce a system like the one I wanted, and I noticed a few other developers also searching for the same thing. So, I’d like to put my take on an NPC system out for other developers to look into and use to their desire.
One of the biggest open-source projects I used and where I started was Vesteria and what that team did in order to achieve mobs for their MMO. You’ll see a good amount of similiarties between mine and theirs. They did a fantastic job at coming up with a method for rendering NPCs/Mobs/THINGS THAT CAN WALK AND HAVE A MIND OF THEIR OWN.
About a week ago I had no idea where to even start, I didn’t know what a state system was, I didn’t understand how I would go about replicating the NPC on the client or anything. Vesteria and the devforum helped a lot with everything I’ve learned.
I’m sure there are a lot of improvments and things you could change to make it fit your standards. This works perfectly for me and provides what I want.
Of course, if you have improvements feel free to let me know, I’m far from perfect!
Credits
I ended up using Knit Framework and its Component tool in order to achieve everything you see. @sleitnick also produced a node mapper plugin and a pathfinder module that uses the nodes produced in the plugin. These were used in order to get he NPCs to follow a set path(You can easily change this if you dont want them to go along a desired path when pathfinding somewhere.) So shoutout to them for being the genius they are and making all these tools for us to use!
Obviously the Vesteria team was a huge help. It was the only game I could find that has an NPC/Mob system and was completely open-source. I am forever thankful to them for putting such a huge and complex game on Github for us to learn from.
Other things on my mind
In the place there are 352 NPCs being spawned. The way I am rendering the NPCs in and out uses the Player’s camera position. Zooming in and out fast with 350 NPCs close to you can(probably will) cause a LOT of lag. So watch out.
The server also uses the NPC’s speed in order to calculate when it should go to the next node. Again, this works for what I want, but it may not be the best way to achieve this. Im completely ignorant to other ways that dont involve communication between the client/server.
I haven’t really “cleaned” anything yet. So watch out if you find something that shouldn’t even be there. Or maybe you find something that SHOULD be there and I completely overlooked it.
I hope this could help someone out and I also hope you have a fantastic day/night!
Thank you,
Ethan
EDIT: I have recently discovered that due to an engine bug on Roblox’s part, the NPCs would not render on mobile. I have gone ahead and fixed this, so NPCs should now all render on mobile. Sorry about that!