Randomly generating -1 and +1

HopscotchHopscotch Member, PRO Posts: 2,782
Hi all, just want to share a little snippet that may be useful.

To randomly generate either a -1 or +1, use random(0,1)*2-1

As an example, this could be used to randomly change an objects linear motion between going left or right, or changing the orbital travel direction between anti-clockwise and clockwise.
Sign In or Register to comment.