How can I randomize two numbers in "direction" slot

Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 305
edited January 2018 in Working with GS (Mac)

My actor spawns and I want him to either go left or right (0, 180)... how do I randomize this in the move behavior?

Comments

  • Two.ETwo.E Member Posts: 599

    One way that would work,

    Create a new Index attribute. Make it change to a random value between 0 and 1.
    Random(0,1)

    Then have two seperate rules for the actor that is spawned.

    When Index Attribute is equal to 0.
    Then Move direction 0.

    When Index Attribute is equal to 1
    Then Move direction to 180.

    Hope that helps,

  • Two.ETwo.E Member Posts: 599
    edited January 2018

    Or,

    Create a new Index attribute. Make it change to a random value between 0 and 1.
    Random(0,1)

    Then have a move behaviour directly below. In the Direction section, open up the expression editor and enter in the following.

    (Index.Attribute*==0)and(0)or(180)

    *You will need to select the the Index attribute. Not the word.

  • Two.ETwo.E Member Posts: 599

    Or,

    If you just want to use the move behaviour,

    You could just add the following into the direction section expression editor:

    (Random(0,1)==0)and(0)or(180)

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 305

    @Two.E Thanks so much!!! it worked. I used the first one.

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2018

    You can also set the direction to:

    Random(0,1)*180

  • Two.ETwo.E Member Posts: 599

    @Socks said:
    You can also set the direction to:

    Random(0,1)*180

    I knew there was a simple way. Almost got there on my own!

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2018

    @Two.E said:

    @Socks said:
    You can also set the direction to:

    Random(0,1)*180

    I knew there was a simple way. Almost got there on my own!

    It's one of those questions with several million solutions !

    You could also do it with the speed . . . .

    random(((0,1)*2)-1)*300

Sign In or Register to comment.