Jump to content

Scrollbar as a value selector


SheriFF

Recommended Posts

What i am trying to make is a character creator system where the stats as age, height and weight must be selected using a scrollbar.The problem is that i can't think of an algorithm to do this

Example : at the height scrollbar the player can choose between 150 and 250 cm. I need an algorithm to work with the guiScrollBarGetScrollPositon and transform it in a value between 150 and 250, how can i do this? ( a general formula would help alot )

Link to comment
58 minutes ago, MrTasty said:

minValue + scrollbarPosition * (maxValue - minValue)

where minValue would be 150 and maxValue 250, you would get something like
euM6Mhp.png

That works great if the scrollbarPosition is ranging between 0 - 1, but AFAIK the GUI scrollbar is ranging between 0 - 100, so a division by 100 would need to be added

minValue + scrollbarPosition / 100 * (maxValue - minValue)

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...