Spawning random actors

kentarosankentarosan Member Posts: 18
edited November -1 in Working with GS (Mac)
Hi there!

Ok, I have a problem an it seems I can´t find the answer in the forum.

I have 5 diferent actors, and 8 spawners in the screen. On the spawner I put a rule to spawn a random actor at a random time.
The objective is to hit the actor before a certain time, diferent for each actor.

But the thing is the actors keeps spawning one in top of the other if i don´t hit anyone. So I can finish with more than 5 actors at the same time in each spawner of the screen at the same time.

Is there a way to tell the spawner to only spawn ONE actor at a time, and don´t spawn another one until the previous one is destroyed?

Comments

  • P373GamesP373Games Member Posts: 17
    I am not totally positive if this would work but you could set up an attribute that when the random actor is spawned goes up by one. you could tell the spawner not to spawn another actor until the attribute reaches zero.
  • P373GamesP373Games Member Posts: 17
    Sorry just now reading that over and i realize it sounds like mush.

    You can set up a global attribute that counts the number of "random actors", it goes up when an actor spawns and goes down when an actor is destroyed.

    You can tell the spawner to only spawn after the counter is equal to a certain number (0,1,2,3...)

    Hopefully that is a little more clear. :)
  • kentarosankentarosan Member Posts: 18
    Yeah, I tried that before, but didn´t work (unless there is a way I don´t know)
    But that attribute should be on the actor, so, how can I tell the spawner to change an attribute on other actor?

    That can´t be done, isn´t it?

    If i do that attribute a global one, there will be only spawning one actor at a time, not one in each location of the spawner if i´m not wrong...
  • kentarosankentarosan Member Posts: 18
    OK, I tried that second way, but the thing is that way works...more or less.

    I have 8 spawners, so I made an attribute setting up at zero, and then each actor make a +1 when spawning and a -1 when destroyed.

    The spawner has a rule to only spawn when that attribute is less than 8, but then the thing is when I destroy an actor, the new actor spawned appears randomly and can appear in top of another one, so i have the same problem again.

    To be more clear, the game is a whack a mole style, but with different types of actors, how is this usually done?
  • kentarosankentarosan Member Posts: 18
    Hi again, I been triying and triying, but can´t solve this problem, Is there anyway to tell the Spawner to spawn only one actor and not spwan new one until the previus is destroyed??
  • JeffreyShimaneJeffreyShimane Member Posts: 372
    How about if you create a boolean attribute for each hole in the whack-a-mole game. When a mole pops up/spawns in a hole, the boolean attribute is true. When the mole gets whacked or drops down because the player didn't whack it in time, the boolean attribute goes back to false.

    Before a mole pops up/spawns, it has to check if the hole is vacant (boolean attribute is false) first. If it's not vacant (boolean attribute is true), a new hole is randomly chosen.

    Hope that's helpful.

    - Jeff
  • kentarosankentarosan Member Posts: 18
    Thanks for that! I´ve never made anything before with boolean attributes, I will try that and see if I can make it.

    Thanks again!
  • kentarosankentarosan Member Posts: 18
    Ok, I´ve been triying with the boolean, and I get an error at the end with the touch control. Let´s see:

    - I have made a boolean called "spawner" and an integer called "Randomspawn"

    - On the Spawner actor I have the following:

    [Rule:
    When All conditions:
    Attribute - game.spawner - is false (it does not work if I put true)

    [Timer:
    Every 1 seconds (cheked Run to completion)
    Change attribute - game.Randomspawn - to random(1,3) (Onl have 3 actors at the moment)]

    [Rule:
    Attribute - game.Randomspawn - =1
    [Spawn actor 1
    Change attibute - game.spawner- to: true ]]]

    (Then the same for the other 2 actors left)

    And then, on each actor, I have the following:

    [Rule:
    When All conditions are valid:

    Actor recieves event- touch - is released
    Destroy
    Change attribute - game.spawner - to false]

    So it works, it does not spawn more than one actor at the same time in the same spawner, but the Touch rule in the actor does not work.
    The actor doesn´t destroy when you touch him.

    What am I doing wrong?
  • kentarosankentarosan Member Posts: 18
    Ok, I checked the preius post and it seems quite confusing, so I upload a few images, the first one is the Spawner behaviors:

    http://img4.imageshack.us/img4/2742/spawntest1.jpg

    Ans this one is 1 actor´s behaviors (they are the same for the rest of actors spawning)

    http://img804.imageshack.us/img804/4175/spawntest2.jpg

    Any idea why is not working? I been hours looking for a solution, but I don´t get anywhere T____T
  • kentarosankentarosan Member Posts: 18
    Any ideas on this one?? 0.o
  • kentarosankentarosan Member Posts: 18
    I´m still with this issue, don´t find a solution.

    I have changed the touch Rule of the actors to "When mouse position is inside" and it works perfecty, also with "Mouse button is pressed". But it seems it does not work with the touch is release control, which is the one I need.

    Are boolean atributes not compatible with touch controls?
  • JeffreyShimaneJeffreyShimane Member Posts: 372
    Have you tried using when Touch is Pressed instead of Released?

    Also, have you tried moving the the destroy behavior to be the last behavior executed? The behaviors after destroy may not be executed, depending on how quickly the actor is destroyed.

    - Jeff
  • kentarosankentarosan Member Posts: 18
    Yep. just tried thee two things and nothing changes, everything is still the same.

    I really don´t get it, can´t figure out what´s going wrong... Starting to think is something with Gamesalad itself 0.o?

    Thanks for the options!
Sign In or Register to comment.