UI Binding Variables for Instances

Hi,

I have 2 actors within the scene that are the same and I want the UI to display their variables individually. For some reason, the UI is display the variables for 1 actor and not the other. Any help will be greatly appreciated :slight_smile: I just don’t know how to bind instances of the same actor. :frowning:

For some reason, the UI is display the
variables for 1 actor and not the
other

Your loop fetches the first actor from the array and exits immediately, it never has a chance to complete iteration. Even if it did (if you used the Complete pin instead), it still would not work. You’d be always displaying the last index in the widget.

Using All Actors of Class is by far the worst way of doing this.


Just to clarify, you want each object to have its own widget, right? Do you create the widgets inside the objects? Or?

The widget is created the moment you pick up the object, which then I use remove from parent when I drop the object.

But yes, I want the widget to bind the variables individually.

It works! :smiley: Yes, I was creating the widget inside of the weapon blueprint. For some reason, I relied on get all actors of class to bind my variables. I know this is bad as it can have an effect on the performance of the game. Thank you for your help! :slight_smile:

The widget is created the moment you
pick up the object

The question is not when but where. Do you create the widget inside the objects? Is your create widget node inside the weapon?


I could just tell you to pass the weapon reference to the widget but that’s, most likely, not enough hence all my question. :slight_smile:

Here’s the general idea:

  • create a weapon object reference variable in the widget - just like your weapon entity but not an array
  • flag this variable as Instance Editable and Expose On Spawn - this will give you an extra pin when you create the widget
  • when your weapon object creates a widget for itself, plug self in to the widget’s additional pin

The above assumes it’s the weapon that created the widget.