User Tag List

Results 1 to 8 of 8

Thread: Setting a value to Random but not to high and not to low?

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Setting a value to Random but not to high and not to low?

    I want to set a value in a single event line to a number between -25 and (+)25. But the value should not be in the range of -5 to (+)5.

    Right now if I do a set value to Random(50)-25 for example the value I end up with could be for example 3 and that is in the range of -5 to (+)5...

    Any idea how to do this?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The difficult part is getting it in one event... But I worked it out for you! Use this formula (make sure you include the brackets):

    (5+Random(21))*((Random(2)*2)-1)

    How it works:

    25 + Random(21) = Any number between 5 and 25

    Random(2) = Either 0 or 1, so:

    0 * 2 = 0
    Or
    1 * 2 = 2

    Subtract 1, so 0 becomes -1 and 2 becomes 1

    Meaning we can use that result to multiply it by either -1 or 1 (picked at random).

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DistantJ View Post
    The difficult part is getting it in one event... But I worked it out for you! Use this formula (make sure you include the brackets):

    (5+Random(46))*((Random(2)*2)-1)

    How it works:

    25 + Random(26) = Any number between 5 and 50

    Random(2) = Either 0 or 1, so:

    0 * 2 = 0
    Or
    1 * 2 = 2

    Subtract 1, so 0 becomes -1 and 2 becomes 1

    Meaning we can use that result to multiply it by either -1 or 1 (picked at random).
    Oh that's a cool solution! Thanks!

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Setting a value to Random but not to high and not to low?

    Pleasure! I like working out math, makes me feel smart... even if it does take me ages

    Edited the post because I got some numbers wrong (misread your original post).


    Sent from my iPad Mini using Tapatalk HD

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    rubes's Avatar
    Join Date
    May 2011
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that is brilliant, Distant J. thanks for the walk through on the logic

  6. #6
    Clicker Fusion 2.5 DeveloperiOS Export Module

    Join Date
    Sep 2006
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice solution DistantJ

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module
    foyzul2002's Avatar
    Join Date
    Nov 2011
    Location
    London, UK
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great stuff! +10

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Setting a value to Random but not to high and not to low?

    Thanks guys! Fun stuff!


    Sent from my iPad Mini using Tapatalk HD

Similar Threads

  1. Random Active Spawn in Random Location in Frame
    By Top_of_the_Temple in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th October 2016, 03:33 AM
  2. Random object spawning random y set x
    By Armiferamortalis in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 23rd December 2013, 11:47 AM
  3. Make Random Pool not-so-random?
    By UltraHammer in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 4th April 2013, 02:53 PM
  4. [BUG] Counter not setting aways>random
    By paobrasil in forum iOS Export Module Version 2.0
    Replies: 7
    Last Post: 19th October 2012, 01:12 PM
  5. Random Speed + Ypos at random times
    By Keehan in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 14th May 2011, 05:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •