How to handle multiple NPC creation with similar blueprints but different spritesheets/flipbooks

So I am in the process of trying to define dialogue interaction between NPC’s and I am a little confused about how to handle this correctly without reproducing oodles of blueprints unnecessarily.

I am using a line trace from my playable character to check if the player is interacting with NPC0 via a cast to NPC0, if cast failed it checks for NPC1.etc. All of these casts do the same thing afterwards, it fires the ‘Talking’ custom event from the corresponding NPC blueprint, brings up a generic dialogue hud and disables movement. Can this be streamlined somehow?

Here is the resulting call from NPC0 that defines the idle flipbook to use so the NPC turns to the player.


I am wondering if an Actor Component blueprint is the way to go here, cast to that then somehow call which NPC flipbook, datatable name/dialogue.etc to use. but I don’t fully understand the ins and outs of how or what I should set up my paper2d NPC’s as. They are currently Paper Flipbook Actors. Should they be classed otherwise?

I hope this is somewhat clear… Ideally I would like to have a base NPC template that I can reuse with every NPC that basically says, if interacted with via the line trace, call the appropriate flipbook for that NPC so it looks at the player when interacting.

Long story short, I am very confused how to handle NPC’s efficiently that all act mostly the same, but have different dialogue datatables and spritesheets…

God, I am confused and a bit of a nub :smiley:

The easiest way to do this is to change the flipbook animation as you spawn the actor.
Provide a variable on your actor of the correct type for the animation. Then check the “expose on spawn” and “editable” checkboxes.
Then, inside your construction script or inside Begin Play (I prefer Begin Play,) get the value of the variable, and set it to your animation component’s animation property.

When you get to spawn the NPC, the Spawn Actor node will now have the variable you configured as a pin you can provide a value for!

If you just play NPCs in the level, you can then drag your blueprint into the level, and then re-configure only that variable value for each instance.

This sounds ruddy marvelous, thanks jwatte! I didn’t realise that ‘expose on spawn’ was a thing.

I am sure I will have more questions but all seems very clear. I will delve into this when I get the chance, hopefully tomorrow