I’d like to use UMG to create two sliders: one called Speed and the other Strength. Lets say 1-100 is the range of the sliders, and they both start off at 50. I’d like them to work so that if you change one the other automatically changes as well. As an example; if Speed is at 75, the Strength is automatically set to the 25. Or if you change Strength to 65, then Speed is automatically set to 35, etc.
So “MyCharacter BP” has two Floats: P_Strength and P_Speed. Both are set to .5 (Assuming 1 is the max). Those are public.
In “MyHUD BP”, in the Designer view I have the Strength slider set to .5. I’m not sure if you want me to ‘Bind > Create Binding’ on the Speed slider? If so, can you give me an idea of what to do within the Binding please? I’m a bit new to BP and UMG…
Event Construct - In your widget blueprint, is the first thing that gets called after the widget is created.
Sequence - Nodes that come out of are executed one after another
Set Value - node sets the value of a UMG slider (0->1)
Same as 3
Reference to your character blueprint
Get Speed from your character
Get Strength from your character
A reference to your speed slider
A reference to your strength slider
Reference to your character blueprint, same as 5
A reference to your speed slider, same as 8
A reference to your strength slider, same as 9
OnValueChanged - called whenever a slider’s value is changed by the player. Find it in your designer view with your slider selected
Set strength variable from your character
Set speed variable from your character
Math node, 1 minus value from OnValueChanged
Set value of a slider, same as 3 and 4
Same as 13
Same as 15
Same as 14
Math node, 1 minus value from OnValueChanged, same as 16
Same as 3, 4, 17
When the widget is created (1), set the value of your Speed slider (3, 8) to be the same as your character’s (5) Speed (6), assuming it’s between 0 and 1. Then set the value of your Strength slider (4, 9) to be the same as your character’s (5) Strength (7).
Then whenever your player changes the strength slider (13), it will set your character’s (11) Strength (14) to be the value of said slider (13). Then set your character’s (11) Speed (15) to be 1 minus the value of the slider (13, 16) and set the value of the Speed slider to be the same as that (10, 16, 17).
Finally, whenever your player changes the speed slider (18), it will set your character’s (11) Speed (19) to be the value of said slider (18). Then set your character’s (11) Strength (20) to be 1 minus the value of the slider (18, 21) and set the value of the Strength slider to be the same as that (12, 21, 22).
Here’s how I would do it, you’d need to do some slightly different math if you want to use whole numbers, I just use the 0…1 range the slider expects. You’d just need to format it in a function by dividing by the Max Int/Str value to get it into normalized space.
I’m working on a simple project, building an app for Cephalometric analysis lessons. I managed to import my models, and build the UI (UMG), but i’m stuck now. I need to “link” UI sliders to my model morph target.
For example, when i move Slider one, my model start to morph to morph target one … Just like a character customization screen.
I’m not a programmer but in my mind, i need to get the morph target value to a variable and use the slider to increase or decrease value. Can anyone help me with ?
I don’t know if i did it right, but i have the SliderValue variable (its should be the umg slider) and the MorphValue (its should be the mesh called Morpher, morph target called morph_01 value), now i’m stuck again
The HUD is on screen, the mouse cursor is on screen … all working but can’t control the morph target with the slider :mad:
In your HUD, you should create a handler for the slider value changing, and set your morphers value when it changes. Then you should create a binding for getting the slider value to your morpher’s value (normalized 0…1).
Should i remove all i did in the character blueprint (i meaning the slider and morph part) ?
I’m not sure if way to get the morph target value and put in a variable is correct. Is it ?
The target is my a BP actor that contain my skeletal mesh with morph target called Morph_01 … so the only node i found was one “get morph target” but i not sure if its right to use it way.
Lets say its right, then i put part on my HUD and bind the slider with the “get morph target” return value variable, MorphValor in case ?
Also you need to connect up the Set nodes, right now you are not passing in Exec wires so they are not being called.
You need to connect it up similar to , I used yellow to mark the pins that need to be connected (just make sure all of the Exec inputs are used otherwise it will not work):
I tried that way, and result in some errors, and i realize that was the wrong way to do it. Now i set all way:
1- Put the part that create HUD, set input mode UIOnly with mouse enabled in my character blueprint. Its working, i can see the HUD, slider is moving and cursor always on.
2- Create an event OnValueChanged for the slider in my HUD widget blueprint, and set way. Again, i’m not sure if its right but there no more errors on compile.
Now the slider is moving when playing the game but nothing happening. I added a print string “CAST FAIL” on cast failed, and its failing, maybe i missing something or doing something wrong … any help ?
and thats why i always recommend to create UMG Widgets inside the controller class.
First: Sure your cast fails -> you dont have any instance of BP_BoxActor given -> so casting NULL into NULL will return in NULL.
Second: just because im a bit dainty. Rename your HUD Widget into “HUDWidget” because when i read HUD i dont expect you are talking about a widget (HUD != UMG Widgets)
Third: Place your Code (within the Draw UI Comment) into the player controller class why? you need the reference to a player controller anyways.
Fourth: (In Player Controller) On Begin Play -> Create Widget -> just to be clear set a reference to “self” to the Owning Player Pin -> Output Pin save in variable (you already do so) and add reference to viewport
Fifth: (In Player Controller) Delete the Get Player Controller node -> you dont need it anymore
Sixth: Go inside the widget -> Add a Custom Event or a Function with the input of your incoming morph value -> take pin to set your widgets variable where your slider reacts to.
Seventh: Inside your character -> Add On Begin Play and set your Morph value in the way you did.
Eighthly: After the node Add to viewport -> Call Get Character/Controlled Pawn -> Get the Morph value || Get your Widget reference->take the outpin and call you event i mentioned in 6. - connect the value from Character with the call event input.
additonal: to set your input node he want your player controller reference and the widgets reference in order to setup it to be active. I even wonder why it doesnt complain about it.
I did part of these steps already, 1st step removed all that part, 2nd,3rd,4th,5th done.
At 6th step …Should i create function by bind at slider value ?? and the return value will be my SliderVal (float variable) ??
At 7th step … you telling me to set the morph target inside my character blueprint, but my character is just a static camera and have no mesh or morph targets … its an object in the scene that have the mesh and morph targets. So i set 7th step in my object blueprint or still in my character blueprint ??
Your videos helped me on how to create these functions. Thanks.
Hey . I’m trying to get to work, and I’m noticing that the left part of your video is getting cut off. I created two float Variables in the EventGraph on the User Widget and made them public. On the Designer I bound them to those variables. I created your Blueprint with the “Sets” and “OnValues”, and used .1 for the Float - Floats. But I still cant get that functionality. Any thoughts? Thanks!