Page 1 of 1

How do I randomize the state of a Switch?

Posted: 09 Feb 2013 01:57
by danielmkarlsson
Hello.
I would like to randomize the state of a switch w/ a pad.
I'd be very grateful for any help I can get.

All the best

Daniel M Karlsson

Re: How do I randomize the state of a Switch?

Posted: 09 Feb 2013 03:56
by brianc
The x value for a switch can only be 0 or 1. rand() gives you a number between 0 and 1 that is not likely exactly 0 or 1. You can fix this in your script by rounding the random value:

Code: Select all

UltraSoloSwitch.x=round(rand());

Re: How do I randomize the state of a Switch?

Posted: 09 Feb 2013 04:10
by danielmkarlsson
Right. Integers and floats.
Works like a charm now.
Thank you very much for your help brianc.