Jeffiec_c
Jeffiec_c

Reputation: 55

Run away variable

i have a small function in a collision event in Game Maker, for some reason once triggered, the variable is supposed to increment, by another variable, it just runs off and keeps increment to max. here is the code.

if(global.rep <= 5000){
    global.rep +=  rep_gain;
    global.poop_time = poop_time - 5;
}

if this is in a collision event it should only fire once, the variable rep_gain is an irandom(5,10), but it will just keep running to 5000 which is max.

Upvotes: 0

Views: 164

Answers (1)

chessprogrammer
chessprogrammer

Reputation: 788

In game maker, the collision event is constantly called until the collision is addressed by making the 2 objects no longer collide. if you don't do this, then the variable will increment until max.

Upvotes: 1

Related Questions