playMaker

Author Topic: Random Range from float value?  (Read 4062 times)

derkoi

  • Full Member
  • ***
  • Posts: 187
Random Range from float value?
« on: August 21, 2013, 05:01:12 AM »
Just wondering if anyone has made or can make an action you can enter a float value and a value above and below it and it picks a value in that range at random?

So if the input float value was 1 and my max and minimum range were 1 then I'd get a random result between 0 and 2. If my input float was 5 and the ranges were 1 min and 1 max I'd get a random value between 4 and 6.

Hope that makes sense.  :)

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Random Range from float value?
« Reply #1 on: August 22, 2013, 02:38:47 PM »
Nevermind I've made one myself.  ;D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15594
  • Official Playmaker Support
Re: Random Range from float value?
« Reply #2 on: August 24, 2013, 04:22:49 AM »
Hi,

 How did you managed to do it?

bye,

Jean

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Random Range from float value?
« Reply #3 on: August 24, 2013, 04:31:23 AM »
Basically, it takes the input value and subtracts the users lowest value to use as the low range limit and adds the users highest value for the users high range limit:

user inputs
Input float = 2
min range = 1
max range =1

min range subtracted from input = 1
max range added to input = 3

random range between min & max (between 1 & 3)

Thats it.

I've also made another action the same as above but only processes when the input value changes. I'll add them to the custom actions forum.  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15594
  • Official Playmaker Support
Re: Random Range from float value?
« Reply #4 on: August 24, 2013, 07:40:34 AM »
Hi,

 Thanks!

 Jean