Moving an Actor with UMG Slider

Hey everyone,
I am trying to build a desk with adjustable height. I want it to move up and down with an UMG slider in a widget.
I’ve allready managed to hook up the slider value with the “AddActorWorldOffset” node, but it just keeps moving in one direction (up or down), no matter what direction the slider is pulled. I know why it is doing this - so I am looking for a solution to this.
Is there a possibilty to get acces to the slider direction directly or at least check whether its value is increasing or decreasing?
I am kind of stuck here and any help or hint would be greatly appreciated :slight_smile:

Hey Chrizzlon, I also am trying to achieve a similar task but in a different way than how you are, I think. I’m sorry in advance if none of this helps. Back in May of last year I chose what I thought would be an easy task to help me understand blueprints (make a slider and have it move an actor left and right). Turns out it was more difficult than what I was capable of and it may have been too rare of a situation to find other people asking this question or to answer my question (i never got a response). I started trying to do it again just yesterday and I think I am about in the same spot I was before. Hopefully I can give you what I know so far and perhaps one of us can find the solution and document it here to help the next guy. My initial attempt came from this question asked here: How can I make a slider control the y position of a static mesh? - UI - Unreal Engine Forums and I think he figured out how to do it but as you can see I posted my version on there that did not seem to work. Today I am referencing that post and this one: How can i send events from widget to level blueprint - UI - Unreal Engine Forums which looks like is using a similar method but the end result is simply to print the string to show it is working.

Currently I have that string printing and it is showing the value as I slide it so I think I should be able to get an actor moving with the same slider using some of the information provided in the first link I posted here. I will post my progress as soon as I know more or get it working, for now I need to go to bed. Hope this helps!

EDIT: I stayed up a bit longer. That first link I sent you is a bit old so I think the node “SetWorldLocation” has now been changed to “addActorWorldOffset” and I have it printing the string and moving in only one direction like you said yours was doing. Tomorrow I will try to figure out how to solve that, for now I am stumped and need to sleep for work.

Rather than do that, pass the “Height” variable to the desk, and then have the desk change itself to fit the height decided by the slider. (Set actor scale\location to constant * SliderHeight)

Thanks for the help aureon. Personally I have been trying to utilize your recommendation but I feel that I am just far too inexperienced to decipher what you mean and how to make it into a blueprint. Right now here is what I have:

this is my level BP

and this is the BP to my actor

Right now I’m in the same place as the OP (sort of) and that my slider starts in the middle, when it moves left it goes into negative values and moves the actor “ThatGuyFlipbook_blueprint” left, but if I move it right while it is still in the negatives it continues to move left. Once I move the slider into the positives it goes right. Can you perhaps tell me how to convert what I have here to what you are recommending? How can I make it understand that ‘set actor location to constant X Slider negative/positive’ aka when slider is moved left at any time actor moves left and any time slider is moved right actor moves right, regardless of the current negative/positive position of the slider?

Any advice would be most appreciated.

Edit: here is my widget BP in case it is needed in some way:

Okay, much like the OP, you’re mistaking an absolute value for a delta.
In that, i mean that the slider is delivering to you a 0-1 value every frame - but you’re interpretating that as if it was a delta (A delta is “Last value - current value”).
This is a very important distinction to make, for that currently this is what’s happening:
Slider: My current value is 0.4!
Your blueprint: “Okay slider, 0.4 registered! Table, move yourself 0.4 units to the left”
Instead, this should be happening:
Slider: My current value is 0.4!
Your blueprint: “Okay, slider, 0.4 registered! Table, set your position to 0.4!”

You need to use Set position, not add local offset - because you’re adding a total every frame.
This is roughly the construct you need:

http://puu.sh/ndf3W/3602149e14.png

However, i’m also going to expand on my original answer - With the qualifier that this is purely about code quality and may be subjective, and will not be strictly needed to get your code working:
You shouldn’t put “business logic” (eg. code that actually DOES something instead of just manipulating data) in UMG, because you may want to modify the height of said table from other sources - and you may come back to it later, and fail to understand why the table is behaving oddily.
Instead, if you put the variable “Height” in the Table, and let the Table’s tick take care of actually doing the SetActorLocation, you’ll know easily why your code is misbehaving - Worst case, you’ll need to track down why the Height variable is changing, but you can tooltip that.

Anyhow, an alternative implementation using AddOffset, so the table can move independently while it’s height is being controlled by the slider:

http://puu.sh/ndfnr/d75e0906bc.png

I was unaware of the differences on setting the actor location. I will tinker around with it for a bit and try your different methods, at the moment I have only replaced the AddActorWorldOffset with SetActorLocation and that already has it functioning as I need. Thank you very much for all your help and for the detailed explanation.