Is there a co-block that can alternate or randomize two sets of code?

Hi! I’m trying to find a co-block wherein the game will choose which path the angel will take. I have already created two paths, I just need to find a co-block that can randomize which path the angel will follow.

I’m doing this so the player won’t know which direction the angel is coming from.

2 Likes

set variable to random number between 1 and 2

if variable = run a code
else = run other code

2 Likes

Hi Alessio! The code still doesn’t work :(. Am I supposed to put something in the number 1?

I also noticed when changing the sign, the path’s change. Greater than sign makes the angel follow the first path (the path going to the right) while less than sign makes the angel follow the second path (the path going forward). Equal sign just makes the angel follow the second path. Maybe there’s a way or code to switch the signs when pressing play?

Thank you for your help by the way!

2 Likes

put it to = 1 and it will work.

2 Likes

Hello! It still doesn’t work :(. The angel still follows the second path.:frowning:

1 Like

can you show me the full code?

2 Likes

Shouldn’t it be “random integer” instead of “random number”? Otherwise you can get 0.1, 0.2 etc. and never get just “1” so it will never take the first path.

image

4 Likes

Oh! It works now… Thank you so much!

(I wish I could give both of you “solution” :'(. I’m so sorry :slight_smile:)

3 Likes

thank you for clirify the situation

3 Likes