playMaker

Author Topic: Normalize sliders.  (Read 1436 times)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Normalize sliders.
« on: September 17, 2017, 12:49:45 PM »
Hey, guys! It should be a default knowledge for a real programmers, but i'm not, so i'm here,  asking for help  ::)

How can I normalize bunch of sliders in realtime? So the sum value of all sliders not exceed the 1. For example I have 3 sliders with [0..1] range with zero position.
1. Moving first to 1 -> all other stay at zero
2. Pushing second to .5 -> first one automatically sliding to .5 too
3. Pushing third to .5 -> first and second sliding to .25   
 
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Normalize sliders.
« Reply #1 on: September 18, 2017, 02:16:51 AM »
Hi,

Not sure if I fully understand but the principle is to understand mathematical cross product. http://www.wikihow.com/Cross-Multiply

if you have 3 sliders each ranging from 0 to 1, then the maximum is 3. to bring back all sliders sum back to 1 you divide them by 3.

I created an action call floatMap which does that, you give the expected range of your value, the final range it should be in and the value and it will do this automatically.

 so in your case, value is A + B + C, initial range is 0 to 3 and final range it 0 to 1

 Let me know if you still struggle.

 Bye,

 Jean


nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: Normalize sliders.
« Reply #2 on: September 18, 2017, 11:19:10 AM »
Did you mean floatRemap action? I used it a lot and I feel like it this task will be based on this action. But i'm not sure I understand how to link all 3 values and how to make it "everyframe responsive".

Here is a gif of action I want to make
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Normalize sliders.
« Reply #3 on: September 19, 2017, 02:20:37 AM »
Hi,

 ok, I get it, you want to actually control the other two sliders so that as the user is going over 1 in total it's brought back.

 interesting and trick because of the feedback loop...

it will need to be done in a loop fashion, the condition being the sum can not be more than 1
1: Compute the overshoot
2: divide it by two and deduce that on the other two sliders clamping them to 0 ( they can't be negative
3: Compute the overshoot again, go back to 2: if still greater than 1.

Experiment with this. I think that with some more clever mathematics you coudl avoid the feedback loop, but I haven;t had my coffee yet... so brain isn't juiced up yet...

 Bye,

 Jean