Random rotation

IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
edited January 2012 in Working with GS (Mac)
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!

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited January 2012
    if im understanding correctly, you could do this:

    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
  • Rob2Rob2 Member Posts: 2,402
    (random(0,1)*180)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited January 2012
    nice one rob
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Thank you John and Rob! :)
  • Rob2Rob2 Member Posts: 2,402
    Thanks John and Moon :)

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    :)
  • arneeezy88@gmail.comarneeezy88@gmail.com Member Posts: 1
    edited March 2014

    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.

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2014

    @arneeezy88@gmail.com said:
    . . . . at random angles like 45 to 135 degrees ish give or take . . .

    It's rare to see so many caveats in a single sentence ('like', 'ish', 'give or take') :smile: !!

    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.

  • quantumsheepquantumsheep Member Posts: 8,188

    @‌Socks

    That is bloody useful - ty! :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.