I’m planning to add NPCs to my game which is something I haven’t done before, but the current plan is to tag models that are an NPC and then have a script to initialize them (I.e: createNPC(npcModel)) using collection service.
The only thing I’m uncertain about is how NPCs fit into a client server architecture. I assume most of the visuals can be handled by the client like dialogue, animation, movement(?), but for things like quest rewards would be handled by the server.
Typically, in a game where NPCs are consistent between all clients, most NPC logic would be handled on the server. This would include pathfinding, movement, animation, and dialogue logic.
The only work being done on the client (although these systems are just as crucial as the backend for good user experience) would be any interfaces a player might have with these NPCs. For example, if a player walks up to an NPC and triggers a dialogue, a request would be sent to the server which would return whether or not dialogue is available and an initial state for a granted dialogue including response options depending on how you’d like the dialogue system to work.
Server-sided NPCs are easier to create, but not good for when there’s large amounts of NPCs or the NPCs need to be precise in their movements (like an enemy in a hack n’ slash).
The main downside (besides the work that goes into it) to a client-sided NPC is that it gives exploiters more of an advantage since all of movement, attack logic, and hitboxes are run on the client. However, most games that have client-sided NPCs are co-op and singeplayer, so an exploiter can’t really hurt the experience for other players like they would in a PvP game.