How do I create an object randomly in the play area? I'm trying to make monsters come out of the ground every 5 seconds, but I only know how to select the spot. I'm sure there's a way.
Any help?
How do I create an object randomly in the play area? I'm trying to make monsters come out of the ground every 5 seconds, but I only know how to select the spot. I'm sure there's a way.
Any help?












Create the object off-frame, then set the X and Y to random(640) and random(480) or whatever.
.:::.Joshtek.:::.
For some reason its not working. What should the main event be?
I have it like this:
Every 5 seconds/Number of "Monster" >6
and then creates the monster outside the frame. Something isn't working.












Maybe you should do < 6 instead?
Remember, the set position actions must occur after the create object action.
.:::.Joshtek.:::.
Ok I figured something out. Thanx










Ok, guess you figured it out when I wrote this <img src="/center/images/graemlins/smile.gif" alt="" />
What Joshtek said shouldn't need much more explanation, but here's a little detailed example for you.
number of "Monster" is less than 6
every 5.0 sec
create "Monster" at (-50,-50)
"Monster" is out of playarea
set X position of "Monster" to 40 + random (560)
set Y position of "Monster" to 40 + random(400)
The fixed pixels are there to prevent the monsters from beeing created near the edge of the screen
This should do it.
When you get this to work, you should add another condition to test if two monsters are overlapping, and move one of them to another spot.
Ok thanx, that seemed to work. The only problem left now is the monsters appear throughout the whole stage. How would I get them to appear ONLY near the hero no matter where he is in the stage?
This will make the monsters appear around the hero.
set X position of "Monster" to X position of "Hero" - 100 + random(200)
set Y position of "Monster" to Y position of "Hero" - 100 + random(200)
EDIT: this could eventually make them appear out of the frame if the hero gets close to the edge. Alternatively you could make an invisible big sphere object that is always placed at the player's position. Then create "spawnpoint" objects throughout the level (that are invisible too). Now if the sphere overlaps a spawnpoint, select a random spawnpoint and create a monster there. This will prevent them from appearing in obstacles or out of the screen etc, and you can make places in the level where no monsters spawn etc. More control for the level designer.
Besides, Popcorn, instead of "every 5.0 sec" he should use "restrict actions for 5.0 seconds". This is basically the condition equivalent to the "every x seconds" triggered condition. Which means it doesn't need to be at the top of the event to work. Only side effect is that it happens first, and the every 5 seconds instead of in 5 seconds and then every 5 seconds.