Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nFighter on September 17, 2017, 12:49:45 PM

Title: Normalize sliders.
Post by: nFighter 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   
 
Title: Re: Normalize sliders.
Post by: jeanfabre 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

Title: Re: Normalize sliders.
Post by: nFighter 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
(https://media.giphy.com/media/xT9IgpYMX3NRMQdzR6/giphy.gif)
Title: Re: Normalize sliders.
Post by: jeanfabre 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