Random Boolean?

Hi All,
I have an object with a Boolean Variable I created (toggle on / off)

How do I make it randomly toggle once on the events?
Thanks ahead!

set a variable to RandomInRange(0,1)
and then compare that variable. if =0 set boolean to false. if =1 set boolean to true

1 Like

Thanks for the reply,

Not sure if I understood, I know how to do it with normal number variables, but I’m using the built-in Boolean variable option and didn’t find how to do it in the events.

you use another variable (set to random) to set the boolean.

Going by your original post, is this the kind of thing you’re after?

1 Like

Not exactly, I have different uses for Booleans but for example:

I have an enemy character with a Boolean variable: “Choose_Direction” (false = left, true = right)

Let’s say on the start of the game I want this boolean to happens once, and later on (separate event) if it collide some specific object it will also randomly change this variable.

I guess I will have to do some sub-event? or this could be done like in construct with 1 line? (I’m not sure)

I have many other cases that I’ll use Boolean and Random, but I came from Construct where it was native to me, GDevelop is still new to me and I can’t find anything even when I use the search a lot, I need to get my brain understand that this is not Construct things are a bit different of course, especially for noobs like me.

EDIT:
I think I got the basic idea to work, I’ll just have to try with other things rather then keys, should be the same principal I guess: