I have been trying other things (learning in a awkward way) so this isn’t exactly like it was the other day – but pretty close. The npc blueprint has a widget child to the mesh. The widget has a text box bound to “text1”. This is “text1”:
Well, this will never work. You’re getting the same value for all your spawned NPC Guys - you know that already but here’s why. Have a look at the tooltip of that GetActorOfClass node, it finds the first actor in the world. So every NPC displays the first one’s value.
Your NPCs create their own widgets, surely. Can you show how that happens in your case - is it on Begin Play or perhaps you’ve set up a widget component?
So my original loop was working completely correctly (as best to my knowledge/skill). It was how I was getting the UI widget to show the result that was way wrong. I super appreciate Everynone for pointing out mistakes and letting me talk it out loud.
I am still shakey on exactly all the back and forth referencing but I will chalk that up to still being new to UE4. Any advice on improvements/more efficient ways to accomplish this is welcomed!
You’ve created a hard reference to the NPC in the widget. The widget is pulling data from the referenced object every frame (or whenever you access it, I’m assuming here it’s a bound function as demonstrated here. And it will all work fine.
If you wanted to avoid creating a reference and simply assign value to the text block once, you could opt for something along the lines of:
This way you push the data into the widget’s element directly, avoiding a reference; you wouldn’t even need a Base Name variable in the NPC. (although it might be useful to have it there for other reasons, of course!)
There are many ways to accomplish what you needed here. Choosing the most suitable method will depend on the scope, on how complex the system will eventually become and what you expect it to do.