Top : My widget slider value is copied in ‘Slider_value’ variable, which is correctly on screen for each value change.
Middle : I put my widget in the viewport from my other BP and I print on screen the ‘Character_value’ variable, which is working too.
Bottom : Construction script of my BP, where I have a reference to my widget so as to be able to import ‘Slider_value’ and copy it in ‘Character_value’.
The problem is that ‘Character_value’ is always 0, no matter what value is ‘Slider_value’. Seems like I can’t import my slider value this way in my other BP.
This seems to be a rather simple task, but I’m unable to find the right way to do it.
If you have the answer to my problem, I will be very grateful.
After you set the Slider Value variable in the Widget Blueprint, use a Cast node to Cast to Character_BP and on success either call a custom event you first have to create in Character_BP, or alter a variable you also first have to make in your Character_BP and set the variable that way.
In the Character_BP, where are you assigning the Widget reference (the “Widget” listed in your variables on the left)? You’ve used it in the construction script, but I don’t see where it’s being set.
You’re creating the Widget object in Event Begin Play, but trying to pull values from it in the construction script (which is called before Event Begin Play). So, you’re essentially pulling data from a default object (which would explain the 0s).
You should be able to use this logic if you fix these 2 issues. The other option would be to do like Quantum says and get the player character in your widget, and set the value there. Either one should do the job.
Well, in this Widget component, the variable type (details panel) is set to ‘Widget_Slider’, which is my widget containing the slider. So, I assume this is set to the right widget this way (but I may be wrong).
If I drag it in the EventGraph to Set it, I have no items in the Asset list anyway, so it will be empty this way.
Surely I’m missing something to set it right.
That makes sense, but when I put the Construction Script nodes in the EventGraph and connect them, that send me an error message (“accessed None Widget from node Set Character_value in blueprint Character_BP”) and doesn’t change the result (being 0). Maybe it has to do with what you pointed in the 1st point.
Well, that’s what I tried to do in the first place, but it failed.
Just a guess, but the reason your Cast To Character_BP failed is because you are trying to cast the Slider actor as a Character_BP actor. Looking over the documentation on casting, it looks like what you want to do is call a Get Player Character hooked up to the Object node of the Cast To Character_BP. Give that a shot and see what happens.
I’m having a problem with getting data out of the slider as well, but in my case i want to edit the worldlocation of a static mesh with the slider data. would you have any suggestions on how i could do that?
I would suggest starting your own thread and putting as much detail as you can into your request. Be sure to add screenshots of what you have now, and a clear definition of what you are trying to accomplish.