GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How can I randomize two numbers in "direction" slot

Simple Gamer ArtsSimple Gamer Arts Posts: 244Member, PRO
edited January 9 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 Posts: 437Member, BASIC

    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 Posts: 437Member, BASIC
    edited January 9

    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 Posts: 437Member, BASIC

    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 Posts: 244Member, PRO

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

  • SocksSocks London, UK.Posts: 12,821Member
    edited January 9

    You can also set the direction to:

    Random(0,1)*180

  • Two.ETwo.E Posts: 437Member, BASIC

    @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.Posts: 12,821Member
    edited January 9

    @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.