Search code examples
game-makergmlgame-maker-language

How do you do negative random number (gamemaker studio)?


Can you use

irandom(-10,10)

to generate negative numbers? Or does this function provides only number >=0? There is no information in documentation of GML.


Solution

  • A few examples:

    a = -1 * irandom(10);
    
    a = -irandom(10);
    
    a = irandom(20) - 10;
    
    a = irandom_range(-10, 10);