Random Spawning

ZeroCredibilityZeroCredibility Member Posts: 16
edited January 2012 in Working with GS (Mac)
Hi all, new here - I just started digging into the salad and I wonder if anyone here could help.

In addition to my player, which I've already set up. I want to start my scene by spawning say 8 items randomly around the play area. These items will get destroyed so I'd like to replace/respawn some when their number drops below say 5.

I'm totally new and don't know where to start.

Comments

  • calvin9403calvin9403 Member Posts: 3,186
    First of all make 8 actors

    Spawn actor random() in the x and y

    Then make an attribute destroy number int 0

    When the player overlpapaps or collide with any actor, add one to the attribute

    When attribute is greater or equals to 3 you recycle the actors but you son't wnant to spawn thwem again

    And don't respawn, check out some videos in the cookbook, I think there is a recycle actor video there

    Calvin
  • beefy_clyrobeefy_clyro Member Posts: 5,394
    edited January 2012
    If you're game isn't going to be intensive use spawn, if it is recycle but as your new, go with the spawn ;)

    Create 2 game attribute (integer) and call it something like SpawnedItem and NumberofItems

    Then have an actor to take care of the spawning, have a rule inside;

    If attribute game.NumberofItems < 5

    Every x seconds

    Change attribute SpawnedItem to Random(1,8) - access the random function by clicking on the little 'e' for the expression editor.

    Then a rule that says;
    If attribute game.SpawnedItem = 1
    Spawn - Item1
    Position X random (0,480) and Y (0,320) - Numbers depend on your screen area.

    If attribute game.SpawnedItem = 2
    Spawn - Item 2
    Position X random (0,480) and Y (0,320) - Numbers depend on your screen area.

    etc etc

    Then on each of the items to be spawned

    Change attribute game.NumberofItems to NumberofItems + 1

    When item is destroyed, before the destroying behaviour have a change attribute game.NumberofItems to NumberofItems - 1

  • RPRP Member Posts: 1,990
    I recall this vid, maybe it will help for a eyes-on approach.

  • ZeroCredibilityZeroCredibility Member Posts: 16
    Thanks a lot everyone. This will help a lot.
  • ZeroCredibilityZeroCredibility Member Posts: 16
    Thanks again to all on this thread. I was able to get that running.
Sign In or Register to comment.