Spawning in NPCs

I’m at the point in my project where I need to have multiple NPCs in the world. These will be in two varieties. Residents which are my shoppkeepers and customers which are spawned in to buy items from the player. My initial though was that I would just spawn in the Residents from my datatable and then set their data from their. After trying this I found that you can’t pass information to the spawned object. My next idea was to make children from the original class for each NPC. After doing this I don’t see a way to set up the children to be different NPCs as the engine doesn’t seem to run anything within the blueprint and instead just runs the parent blueprints. My questions are thus and thanks in advance for any advice.

How do you manage NPCs. Do you create a different blueprint for each one and adjust their locations when the level starts?
Do you spawn your NPCs are place them in the level as either completely different blueprints or as children of a parent?
How do you adjust information in the child class or is that not possible?

NPC’s should be spawned by the Game Mode. When it does spawn them you can in fact set data on the class. For example you can have a single variable in the parent class… NPC_ID (Name type). The NPC_ID would be a row name from a data table. You can set this to be Rep Notify.

So GM Spawns Actor from Class → Return Value → Set NPC_ID.
The Onrep function in the class uses the value to get the data table row, set vars in the class, call whatever functions etc. Easy Peasy.

Here’s a few examples from my own project.

Currently I have a place holder for character cosmetics. When the server spawns the character via the GM, it immediately sets a Character Cosmetics variable.

The OnRep_Character Cosmetics function in the character class does all the work.


In my weapons class I do roughly the same thing. I use a Name type variable to get a row from a data table to configure various aspects of the weapon class.


Parent class with all the code/functionality that ALL NPC’s will utilize.
Child class with added specialization.

Parent class will have “Config” variables that will be used to Define the type/use of the NPC. You then use those to configure on spawn.