question about the slider and how to attach it to a variables value

what would be the best way to make a slider connect to a variable and slide up incrementally as that value fills up?

like an experience bar kind of thing.

I have a slider in my scene, and I was thinking about it. i feel like i could get this to work by attaching the slider to my experience/rank script, then somehow telling it to be relitive to the experience values. I am un sure how to actually acomplish this though after messing around with it for a bit. Could someone give me an idea where i would go next from here? thanks

The easiest way is to set Slider.value every time experience changes. You can do this inside the setter for experience.

To do it without the experience knowing about the slider you can use an event, again triggered inside the setter for experience.

To totally decouple the classes you can use reflection. But that’s not a path you want to go down just yet if you are posting in the getting started section.

2 Likes

I recommend you watch these: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn

2 Likes

Thank you, I will check out those videos. I will have to remember in the future to try and check out the official unity videos too when i have a question they are done in a really great way. Atleast the ones ive watched so far