does anyone know how to make random items spawn?
Taidaken
Member Posts: 271
Is anyone able to help me with this problem, i cant seem to figure out how to make a random item appear every now and then after a enemy has been killed. any help would be much appreciated!!
Comments
you can maybe destroy an actor when collided and spawn a new actor when an actor is collided ?
-- change attribute randomSpawn to random(1,5)
-- if randomSpawn = 1 then
-- if randomSpawn = 2 then
....
i mean once because i don't want a timer but the enemy to spawn when the enemy before it touches the ground (like in tetris for instance). And if i use a rule such as when collision with actor ... => change attribute randomSpawn to random(1,5) etc...
it does it only once
Such as...
When self.TimerSaysGo = TRUE
self.randomValue = random (1,10)
when randomValue=1 then spawn actor 1
when randomValue=2 then spawn actor 2
self.TimerSaysGo = FALSE (The last rule)
Then in a separate rule have this:
when.TimerSaysGo = FALSE
then>>>
after 5 seconds { TimerSaysGo = TRUE }
This way...only the timer runs when the other rule isn't running.
Its a loop also...but doesn't require the function to fire inside the timer (which has been known to cause problems if things don't fire exactly in sequence)...but instead fires inside a rule boolean. Its a ping-pong loop...the boolean switch bounces back and forth between the timer and the spawn rule set.
Try this...it should work for you.
First I created two attributes in my actor called Spawner (invisible). The first one is a integer called random_value and the 2nd is a boolean called TimerSaysGo.
In a first rule I have :
when self.TimerSaysGo is true
=> Change attribute self.random_value to random(1,6)
=> when self.random_value = 1, spwan ennemy 1
...
=> when self.random_value = 6, spwan ennemy 6
Otherwise : Change attribute self.TimerSaysGo to false
New rule :
When self.TimerSaysGo is false
=> Timer : after 3 secs, change attribute self.TimerSaysGo to true.
That's it and nothing works i think something's wrong because instead of having someting TimerSaysGo, i only have self.TimerSaysGo etc..
Thank you again !
i put an other condition such as " when collides with actor of tag SQUARE"
(because the actors to spawn are different squares, and because the invisible actor (spawner) is next to the ground so the square collides it to reach the ground)
...
When i play the game, one square falls down and when it touches the ground (in fact collides with the invisible actor) make an other square fall down but nothing after
WHY ???