How can I make a widget interact with multiple of the same blueprint?

I have a widget that interacts with a blueprint. It’s meant to change the outfit of a character. I want to have multiple of that character scattered across the level but to keep the chosen outfit on them. When I dupicate the blueprint (multiple of the same blueprint in the same level next to eachother), the widget doesn’t only interacts with one of the blueprints and not both instances. Is is possible to have the widget interact with all of them?

The fastest, yet not the best way, to handle this would be to use the Get All Actors of Class node. Put the class in, do a for each loop on the result, and perform whatever outfit changing shenanigans you need on all of them.

This is expensive and shouldn’t be done on tick, and if you have a lot of NPC’s then you might see hanging if your game isn’t optimized very well.

A better solution would be to have all of your NPC’s “bind” to an event on your widget. To learn more about how to do this (highly recommended), look up event dispatchers and watch a tutorial on them. You’ll want to call a dispatcher when your widget tries to change clothes, and all your NPC’s will bind to that dispatcher at some point in order to react when it’s called.

Good luck!

1 Like