x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: Not Selected
Tags:
more ▼

asked Dec 21 '14 at 07:00 AM in Blueprint Scripting

avatar image

a548922
38 13 15 18

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

alt text

https://answers.unrealengine.com/questions/149384/cast-from-hud-umg-to-level.html https://answers.unrealengine.com/questions/150207/using-buttons-in-umg-to-change-integer-values.html#answer-150231

more ▼

answered Dec 21 '14 at 07:37 PM

avatar image

PeterLNewton
1.9k 69 30 105

avatar image a548922 Dec 22 '14 at 04:05 AM

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

untitled.png (65.3 kB)
untitleds.png (181.6 kB)
avatar image PeterLNewton Dec 22 '14 at 04:20 AM

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.

avatar image a548922 Dec 22 '14 at 04:22 AM

Do you mean bind in behavior or in events onClicked

avatar image PeterLNewton Dec 22 '14 at 04:24 AM

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 .

avatar image a548922 Dec 22 '14 at 04:33 AM

alt text

Its not letting me call it

untitleda.png (85.6 kB)
avatar image a548922 Dec 22 '14 at 04:34 AM

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

avatar image PeterLNewton Dec 22 '14 at 04:41 AM

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 ?

avatar image a548922 Dec 22 '14 at 04:44 AM

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.

avatar image PeterLNewton Dec 22 '14 at 04:57 AM

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.

alt text

avatar image a548922 Dec 22 '14 at 05:09 AM

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?

avatar image a548922 Dec 22 '14 at 05:15 AM

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

avatar image PeterLNewton Dec 22 '14 at 05:45 AM

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

avatar image a548922 Dec 22 '14 at 05:53 AM

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.

avatar image PeterLNewton Dec 22 '14 at 05:21 PM

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

avatar image a548922 Dec 27 '14 at 04:14 AM

alt text

is this the function i need?

untitled.png (96.6 kB)
avatar image PeterLNewton Dec 27 '14 at 04:36 AM

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.

avatar image a548922 Dec 27 '14 at 06:13 PM

Any chance of you possibly doing a tutorial on this in the future on your YouTube page by any chance? I think it would help a lot of people, including me. I'm still having trouble with the functions and casting to line up. I'm gonna keep at it following unreal engines inventory tutorial, and the links you gave me.

avatar image PeterLNewton Dec 27 '14 at 07:40 PM

I have been working on a UMG Inventory for some time. Its not done yet, and I really want to package it for people as a learning tool. It will consist of a fully featured inventory with tutorials on different design techniques I used when approaching it that makes it very robust for many storage uses. It will be released early January. :D

avatar image a548922 Dec 27 '14 at 07:45 PM

Thank you. I will be grateful to have such a video/ tutorial.

avatar image a548922 Dec 29 '14 at 06:37 PM

I finally figured out how to do the end turn feature. Now to do the taxes part. Thanks for all your help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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!

more ▼

answered Dec 21 '14 at 01:02 PM

avatar image

noms
116 5 7 12

avatar image a548922 Dec 21 '14 at 04:05 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question