Help plz

reipor

Member
hello, I want to make a code that makes the system automatically decide one of those objects that I put in the parentheses of choose when the animation ends, but the system always chooses the same sequence of numbers. if I close and open the game, it
gives 5, if I just reset the room it gives 2, but if I close the game and open it again, it will give me 5 again and when I reset the room it will give me 2 again , how do I solve this problem?

GML:
if sprite_index = spr_dado_choose{

    if ev_animation_end{
        
        global.player_dado = choose(spr_dado_01, spr_dado_02, spr_dado_03, spr_dado_04, spr_dado_05, spr_dado_06)       
            
            if (global.player_dado == spr_dado_01){
            sprite_index = spr_dado_01
            global.player_value = 1
        }
        
    if (global.player_dado == spr_dado_02){
            sprite_index = spr_dado_02
            global.player_value = 2
        }
        
    if (global.player_dado == spr_dado_03){
            sprite_index = spr_dado_03
            global.player_value = 3
        }
        
    if (global.player_dado == spr_dado_04){
            sprite_index = spr_dado_04
            global.player_value = 4
        }
        
     if  (global.player_dado == spr_dado_05){
            sprite_index = spr_dado_05
            global.player_value = 5
        }
        
    if (global.player_dado == spr_dado_06){
            sprite_index = spr_dado_06
            global.player_value = 6
        }
        
        
    }
    
}
 

reipor

Member

Roldy

Member
but what i should use instead of choose?
BRO. Read the manual. ---> Choose

From the manual on choose:

NOTE: This function will return the same value every time the game is run afresh due to the fact that GameMaker Studio 2 generates the same initial random seed every time to make debugging code a far easier task. To avoid this behaviour use randomise() at the start of your game.
 
Exported projects don't have this behavior, tho, so if it's at at some sort of working stage and you want to really test your stuff, just make an executable.
As @Roldy said, this is just so it's easier to track stuff when debugging, but the actual exported game is not affected.
 
Top