Spawning random actors

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?
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
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.
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...
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?
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
Thanks again!
- 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?
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
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?
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
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!