Random rotation
IsabelleK
Member, Sous Chef Posts: 2,807
Hi guys!
I have a little logic problem - I have a rule:
Change self.rotation to (I want it change randomly, but only to one of these two valuses: 0 or 180). Random doesn't work properly.
Can anyone help me?
Thanks!
I have a little logic problem - I have a rule:
Change self.rotation to (I want it change randomly, but only to one of these two valuses: 0 or 180). Random doesn't work properly.
Can anyone help me?
Thanks!
Comments
Have a attribute called RandomRot or whatever you want to call it.
Now whenever you want, change attribute RandomRot to random(1,2)
then have rules when attribute RandomRot = 1;
-change attribute self rotation to 0
when attribute RandomRot=2;
-change attribute self rotation to 180
IF for some reason flipping between just 1 and 2 seems to give you the same number to often, you could increase it to random(1,10)
then your first rule have when RandomRot is > then or equal to 1, but < 5
and your second rule have when RandomRot is > or equal to 5, but < or equal to 10
cheers
I am very new and little of this makes sense to me. I am having trouble with my cannon which is located at the bottom i'm trying to get it to rotate and shoot on its own at random angles like 45 to 135 degrees ish give or take any help with this would be greatly appreciated and please be detailed as i'm still learning.
It's rare to see so many caveats in a single sentence ('like', 'ish', 'give or take') !!
If you want your canon to rotate to a random angle between 45 and 135 degrees, then use:
random (45,135)
. . . of on the other hand, like the OP, you want your canon to rotate to either 45 or 135 use:
(random (0,1) * 90) + 45.
@Socks
That is bloody useful - ty!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io