How do I get a sliders value.

I am trying to enable a slider to determine the velocity in which my projectile fires. But first, i need to get the spawner of the projectile to grab the value and give it to the projectile. How would i get the value?

is your slider in a widget? if so then theres a node for getting its value. it should return a 0-1 value which can basically be thought of as a percentage.

255706-capture.png

Yes it is in a widget. Sorry im a bit new but thats photo is in the widget blueprint right? Then i go to my character where im spawning the projectile and how would i give the value to that to give to my projectile velocity ??

you just need to get a reference to the widget so you can access the information it contains. where are you creating the widget? and is there any other instances of it? you could always do the reverse too and when the value of the slider is changed it sets a variable in the player character. the first solution is probably better though.

I am creating the widget in my UMG HUD and not that im aware no instance, I have my projectile being shot from a button that is clicked my character then spawns the projectile. So go to where im spawning the projectile and reference the widget and link it to the spawner?

basically yea. i dont have time to make a elegant solution right now since i need to get to work but ill post a little description of what needs to be done so maybe it will put you on the right path.

basically you need to create a variable in your projectile that will be the initial speed, make this variable public/ editable and check expose on spawn. this way you can set the variables value when its created from the spawn actor node(see picture below). then you need a script in your construction script that sets the inital speed of the projectile movement component to the value of the variable.

then you need to get a way to reference the widget from the player so that we can use the sliders value to modulate a max speed value. i did this here by getting the widget in the hud then getting the slider component then get the value.

i would explain in greater detail but like i said im late for work haha

Thank you ! ill try that out when i can thank you again

ThompsonN13 assumed you’re using the HUD class to store the reference to your widget. I believe you’re not.

Could you tell which blueprint is responsible for creating and adding the widget to the screen?

Here is what i got not sure exactly what im doing wrong any help is appreciated thanks so much sorry im new

your hud doesnt inherit from the character class, so your cast if failing. where does your hud reference variable exist? i was creating the widget in the hud bp but it looks like you may be creating it in the character. you also dont need any of the script that you show in the widget since you will be doing that else ware.

so basically show where you are creating the widget, that will determine what your cast and input object should be. from there it will be super simple.

thanks this is hard lol ill try to figure it out thank you

I appreciate the help but imma take this a bit slower since im getting ahead of myself and screwing it. This is my HUD where my slider exists and im getting the value , like shown in the screen shot attached correct? Thanks again

I appreciate the help this is what i got here imma take it slow since i think im messing it up the more i do it. So right in the screenshot im getting the value of the slider in my HUD where my slider exists. Correct? thank you again

yup Everynone is spot on. i asked where you were creating the widget and you replied hud so i figured hud class haha

yeah im so new at this that i dont even know what im doing im just doing my best here and doesint seem to work LOL hopefully one day ill get this right thanks for the help tho must have been hard to assist a blind man

Don’t give up on this, think about the blueprint that created the widget? Which one was it?

we dont need to see your widget we need to know where you are creating it and adding it to the viewport. i would guess that your doing it in the character bp.

thank you friend this is a widget blueprint i created from the user interface

this is where i have my widget is being created my level blueprint.