Widget instances all using the same data?

I have some gaps in what seems like some basic knowledge concerning widgets and instancing. I have spent a lot of time hammering away at this, and tried many combinations of search terms and can’t quite figure out what I’m missing.

I have an object that I have presenting as an index card in-game. For components, it contains a static mesh (the card) and a widget (to display text and images on the card). This much is working, albeit a little odd-looking since I can’t figure out how to flatten the widget back against the mesh. I’m aware there is a way to project an image of the widget onto the card as a texture, which I’d love to do eventually, but I digress!

The object class itself is a C++ class, which I converted to a blueprint as I could not for the life of me figure out how to spawn more of the object that also contains a mesh and widget - again, something I’m sure is a lot more simple than my efforts would make it seem, and the fact that converting it into a blueprint took care of this particular issue tells me I’m missing something obvious (or maybe is a source of my problem!). The widget reads the variables generated by the C++ class without issue.

The level blueprint spawns 20 of these cards. Inspecting the individual cards shows that they all contain their own randomly-generated data, but each of their widgets is displaying the exact same things - the data from the first card. I assume this means the widgets are not actually being instanced and are all just copies of, or references to, the first and hence are all referencing the first card, but I can’t figure out why.

I suppose the core of the question is, how do I ensure that all the components of a given instanced object are using that instance of the object as their data source?

I’m also wide open to any suggestions as to how to go about this in a much more efficient or practical way. This is literally the first thing I’ve created in this particular project, so scrapping it wouldn’t be terribly painful.

So I made an actor BP, and put a widget component in it. I can set the text on the component using a variable which I can set on the instance, like this:

Is that the kind of thing you mean?

1 Like

I think so, though what I’ve done appears to maybe be the inverse? I used bind functions within the widget blueprint for each individual field, like so:

And when the level spawns the row of cards, this happens:


Notice the attributes on the right panel. Each card’s set is randomly generating properly, but it looks like each card’s widget is using the first card’s data.

If all I have to do to prevent this is do it your way, heck, I’ll do it. I’m still stumped as to why this is happening in the first place, though.

1 Like

Your problem there, is you don’t know which blueprint to bind to. That’s why I did it the other way around… :wink:

You’re using GetActor, which will always give you back the first actor of that type placed in the level. Hence they all have the same details.

1 Like

Aha! That one little detail just made everything click in my brain. Thank you very much!

1 Like