playMaker

Author Topic: How to average sliders?  (Read 2003 times)

Digital Adam

  • Full Member
  • ***
  • Posts: 208
How to average sliders?
« on: February 28, 2014, 04:20:02 PM »
I have two sliders, from 0-100. One slider is at 100, and another is at 0. Those numbers are being outputted into 2 floats. How do you average those two so I can move either slider and get the correct output? As an example; say I move the 1st slider to 70, I want the other to be at 30.

Any ideas? Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: How to average sliders?
« Reply #1 on: March 04, 2014, 07:04:31 AM »
Hi,

 you have to check who is in control and update the one that isn't, it's messy but otherwise you woul dneed to have multiple binding framework in place, etc etc.

What ui framework are you using? Unity GUI, NGUI, 2dtoolkit else?

typically, abstract the value you get from a slider and the actual value you use for other part of your game to read. so the output of the slider is not the same variable as the input.


now, as one slider is changed by the user can catch that difference and fire a global event "REFRESH VALUE" and pass the new value, you fire that excluding the fsm that sent it, so everything else but that fsm will refresh and that's how you bind things up without getting into infinite loops


Bye,

 Jean