Two Widget one blueprint

Hi All,

Just got a bit lost here.

I am trying to create a wall that demands the player to pay artefacts to enter. I create a widget, then a text. Set up a variable on my wall called artefact price I find that arteface price in my UI widget but it does not display in the view port.

Any idea what I am doing wrong?

I don’t know which way you want to send the text, but this is sending it from the character to the widget:

In my player ( I see you have a line trace ):

In the wall BP:

In the widget:

331266-screenshot-3.jpg

I can click it and send my player location:

Maybe I described the problem badly.

I just want to have a wall that has a variable I can display on it. I want to change the variable per instance so one wall says “10” another says “100”

Makes sense?

In your image under In the wall BP it says get widget, I dont see that. Maybe im getting this all wrong. I create the text variable on the widget right?

Yes, and set it from the blueprint.

How do you make that Widget Component?

In the blueprint:

I must be an a simpleton. I am so lost in whats what here. So sorry

I dont have “get widget” as an function option im afraid,

Look at the pics :slight_smile:

In your BP, use GetWidget, then cast to your widget, then set the variable.

You do when you pull the pin from your widget component.

I got it to work by using the “Get user widget object” that did the trick! I have done 2 major c++ classes and a blueprint class on UDEMY and the moment I sat down and I am toying with this on my own, I am ABSOLUTELY lost.

Even with help I think getting my hands in the dirt and not following a recipe is the way to go to learn this. Else it just doesnt stick.

I cant thank you enough, I will keep spamming the forum, this place is fantastic.

Yes, that’s right. Just skip the player bit.

Hey, here is another solution (a little bit advanced):

  1. I created a widget called Paywall_W
  2. Added a button with text and a seperate text

  1. Created a blueprint of type Actor called Paywall with a StaticMesh and a WidgetComponent
  2. Set a wall as my StaticMesh and the Paywall_W as my WidgetClass (scaled it down and moved it a bit)

And now let’s add some functions to the Paywall blueprint

“Why?What?Where?When?”:
With EventBeginPlay we create our references to the widget Paywall_W (PaywallRef) and to the character (CharacterRef). With these references we have access to variables (etc.) within these. Then, from the PaywallRef we get the CostText and set it to a number (like 123) with a variable of type text called Cost (InstanceEditable). So there is a text/cost we can change. After that we bind 2 events to the button from our widget. Drag the pin from PaywallRef, get CostButton, drag the pin from CostButton and add BindEventOnHovered and BindEventOnClicked. To add CreateEvent drag the red pin Event and add CreateEvent from EventDispatchers. To be able to choose OnHover() or Pay() you have to create those as a CustomEvent. OnHover displays a text on the button and Pay subtracts the Cost (visible on the wall) from our Coins. The Coins variable is of type integer and has to be added in ThirdPersonCharacter.
To be able to interact with the widget on the wall there also has to be a WidgetInteractionComponent in the ThirdPersonCharacter. The WidgetInteractionComponent has a function called PointerKey. When this Key is pressed (for a button you want LeftMouseButton) you click the button. You can enable ShowDebug to see a line representing your character “aim”.

A small video showing these functions: