choose randomly between 4 actors?

developer6810developer6810 Member Posts: 139
edited July 2012 in Working with GS (Mac)
I know to choose randomly between 2 objects, you create an attribute that is valued at 50 and then you have the computer choose randomly between 0 and 100 and if the attribute is greater than the chosen number, you pick one actor and if it is less than, you chose the other. How would you do that for 4 actors?

Best Answers

  • HC_DKHC_DK Posts: 92
    Accepted Answer
    Use the CHANGE ATTRIBUTE behaviour: game.YOUR SPAWN ATTRIBUTE to random(1,4)
  • jamie_cjamie_c ImagineLabs.rocks Posts: 5,772
    Accepted Answer
    Something like this:

    Set up a game attribute called "pickActor"

    then when you need to pick the random actor do this:

    Change Attribute pickActor to random(1,4)


    Set up 4 Rules:

    Rule 1:

    If pickActor = 1 then pick your first actor here.

    Rule 2:

    If pickActor = 2 then pick your second actor here.

    Rule 3:

    If pickActor = 3 then pick your third actor here.

    Rule 4:

    If pickActor = 4 then pick your fourth actor here.


    Then you have randomly picked 1 of the possible 4 actors.

    Jamie

Answers

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Exactly the same way, but choose randomly between the numbers 1 and 4, then each number has a 25% chance of being picked.

    Jamie
  • developer6810developer6810 Member Posts: 139
    So what would the attribute (in the other example 50) be since there is 4 numbers and only < and >?
  • HC_DKHC_DK Member Posts: 92
    You can have 4 rules, one for each number.

    If ATTRIBUTE = 1 then

    If ATTRIBUTE = 2 then

    HC
  • developer6810developer6810 Member Posts: 139
    Would there be 4 attributes instead of 1 and the thing would be if attribute is = to random #?
  • developer6810developer6810 Member Posts: 139
    You can have 4 rules, one for each number.

    If ATTRIBUTE = 1 then

    If ATTRIBUTE = 2 then

    HC
    Wait is it the same attribute each time?
  • HC_DKHC_DK Member Posts: 92
    One attribute where you use: random(1,4)
  • developer6810developer6810 Member Posts: 139
    Wait do you put change attribute for change attribute... to random (1,4)
  • developer6810developer6810 Member Posts: 139
    thanks everyone
  • edhogshireedhogshire Member, PRO Posts: 12
    Do you guys have any examples of this? I would love to see a proj file with the option of being able to chose your character at the beginning of the game.
Sign In or Register to comment.