• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How do you change the persistence of an object back to false?

F

FactorX12

Guest
So, I am making a game and I want to be able to toggle persistence of an object whenever the person presses "E". When you press E, the way I have it, it doesn't even set it to persistent the first time. Then, you do it again, and it sets persistent, but once it's set persistent it doesn't set back to non-persistent. Any help?
 
S

Sn3akyP1xel

Guest
First thing that comes to mind, is your 'E' press read once, if it's being read as pressed the key may set it back to on/off in a fraction of a second.
 
F

FactorX12

Guest
First thing that comes to mind, is your 'E' press read once, if it's being read as pressed the key may set it back to on/off in a fraction of a second.
well, "key press e" is a single-read event right?
 
T

The Shatner

Guest
So, I am making a game and I want to be able to toggle persistence of an object whenever the person presses "E". When you press E, the way I have it, it doesn't even set it to persistent the first time. Then, you do it again, and it sets persistent, but once it's set persistent it doesn't set back to non-persistent. Any help?
Well, this code should work:
Code:
STEP EVENT
if (keyboard_check_released(ord('E')) {
       persistent = !persistent
}
This way, everytime you press(actually, release) the "E" key, the object changes its persistence from true to false and vice-versa.
 
D

Dracodino300

Guest
Just adding to the above: keyboard_check_released or keyboard_check_pressed would work fine, just don't use keyboard_check (as sn3eky said).
 
M

MirthCastle

Guest
Why do you want this? What do you think persistence does?
 
Top