Guys, I’m a total newbie. I want to make a mini game with a constantly moving slider slider. I want to split the slider into 3 colors. An example of a slider as in the picture, only split it into 3 different colors. When the player clicks on the button, he will stop the slider by selecting the color he likes. The problem is that I can’t use Widget BP to make the slider move continuously, divide the scale into 3 colors.
Help please
so… A simple approach out of my kind… Since i’m not at home right now:
Creatr a new UserWidget, call it “MinigameBar”.
Create an Overlay.
Inside that, put a horizontal box.
Inside the box, put three Images and color then as you wish. You can scale them as you like, too.
Back to the overlay.
Add a Slider and make sure, to push it below the horizontal box.
Reason:
An overlay renders its content from top to bottom, above each other. Means, the slider should be rendered on top of the box, by adding it below the box in the overlay child list.
Set the Backdrop Color of the slider to alpha of 0.0, cause you don’t want to show it.
Use an Image you like as a thumb image or stay at the default one.
Now the tricky Part.
The slider has a value that, by default, reaches from 0 to 1.
We will work with that.
Set the bool to use it as a variable to true.
Call the Slider “Indicator”
In the Widgets event graph, we need some Variables:
A float, we call “Gaining”.
A bool, we call “Started”.
A float, we call “CurrentValue”
In the Construct Event, set the Value of Gaining to 1.
Take your Indicator and setValue to 0.0.
Now, add a custom event and call it “StartMinigame”. All this event is doing is setting Started to true.
Now, add the TickEvent.
First add a branch that checks, if Started is true.
If false, do nothing.
If true:
Take your Indicator and getValue of it.
Ask, if CurrentValue is < 0 (With a Branch).
If true:
Take your Indicator and serval to 0.
Set CurrentValue to 0.01.
Set Gaining to 1.
If false:
Ask if CurrentValue is > 1 (with a branch again).
If true:
Set Indicator Value to 1.
Set CurrentValue to 0.99.
Set Gaining to -1 (!!)
If false:
Take the Delta output of the Tick Event and multiply it by Gaining.
Add the result to CurrentValue.
Now, setValue of the Indicator to CurrentValue.
Last Step:
Add a new Function and Call it “StopMinigame”. amake sure to not add an Event - We need a Function here!
As Return Value, set a float and call it “ResultingValue”
In the Function, set the Started to false. After that, take the CurrentValue and link it to the Return output.
When you create this Widget, nothing happens. You need to call StartMinigame for it to run.
Now, if your Player hits a Button or Presses an Input (your choice), call StopMinigame from the widgets ref.
This will stop the thumb of the slider and return its current Value.
Just check against it
f.e.: “val > 0.3 && val < 0.66”
To make sure he hits the middle field.
It’s quite likely there will be as many ways to create a minigame like this as there are people. Here’s the most minimalistic thing I could think of:
- a widget with a border (material goes here) and a slider with Alpha tint set to 0:
- the slider handle is pushed around forth & back - you may want to add a curve to make the movement more interesting and challenging
- a material that will definitely require more work, this is just a crude quickie:
- end results: