I want to generate a random boolean to select random direction of rotation (for an asteroid if you're interested :) )

+4 votes

You could do something like this:

```
var dir = true
if randi() % 2:
dir = false
```

On the other hand, if you're looking for a random rotation direction, then what you really want is either `1`

or `-1`

, which you can get if you raise `-1`

to a random power of 0 or 1.

```
var random_dir = pow(-1, randi() % 2)
```

- All categories
- Engine 33,347