Using buttons in UMG to change integer values.

I am attempting to figure out how to update a value in myplayer blueprint after clicking a button in my widget screen. I am trying to set up a widget that when opened, will let you select the tax rate you want to charge your population with. I have all the values and formulas, just don’t know how to update the value after selecting the tax rate button. Any thoughts on this. Been at it for 8 hours watching videos and reading forums.

Any help appreciated.Thanks!

Hi Buddy!

I had the same worries when I was first learning UMG… Your solution is casting my friend!

In your OnClicked function in your widget, you’re gonna want to get the Player Character and then cast to the specific character class you’re using (I.e. ‘MyCharacter’) after which you’ll be able to access all of the events and variables of your character blueprint!

I do this a lot for in game menus and such, and it works a charm. Let me know if you need any additional help or am example.

Hope this helps!

If you have time, can you please show me an example? I would greatly appreciate it. I have been trying since this morning to figure it out.

You’ve created duplicate post my friend. Here are some relating post to answer your question. Instead of using an Event Dispatcher, call a Function on the PlayerController / Character .

More specifically this image here is what you can do in your situation.

24572-onuserwidgetblueprint.png

1 Like

Did you add a bind to the Slot in the UserWidget which is being clicked to execute the OnClicked_Event that you have on your MyPlayer ? That’s the only thing I see missing here.

So when I try to do the call portion of the blueprint, its not finding anything. What am I doing wrong?

Do you mean bind in behavior or in events onClicked

Its not letting me call it

Thank you for being patient with me. Still new to all of this.

The UserWidget which is being clicked on is receiving an Event that its being clicked. This UserWidget Event needs to call the Event you have created on your MyPlayer .

Not a problem, let me get an understanding of what you have going. Basically, the Player is increasing / decreasing a value on the Pawn using Buttons within UMG ?

Makes total sense - sorry for the lag on my end. Internet service is spotty, let me know if this works for you! Call the function with the button event you created with the Widget. Don’t get thrown off my the name switch to IncreaseValue, I did that because of conflicts on my BP.

So the idea is its an end of turn button that causes the tax to increase the credits every time i hit the button Just like in civ 5). Then with this I figured I would understand how to then do a choose the tax rate widget. Let me know if this is making any sense to you.

Its no worries. My internet is slow too. So the part I’m not getting apparently is the call function. So I go into my widget blueprint, do the exact same thing you do, but when I try to call the function, it does not find the function. Is there something that I am not doing?

Can you please show me an example of the function that i need for this please?

I don’t Think i created a function. Let me figure out how to do that and ill let you know if I get it to work tomorrow. Thank you a lot for your help. It means a lot.

Did you create a function in your MyPlayer? Search for the name of the function, don’t type ‘call’ or anything else.

Hey! If you check out this page, it will help you with that. If you scroll down to the damage health example, its similar to your function which needs to increase tax.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Functions/index.html

is this the function i need?

Yes that should work. Calling that function from UMG and supplying the int would allow you to directly change the value. Just make sure to populate this function with scripts to increment your Tax Rate up or down as necessary.