Random spawn objects

Discussion and feedback on Construct 2

Post » Sat Nov 07, 2015 8:14 am

So, I've seen a few posts touch upon random spawning but it wasn't quite what I was looking for.

I'm making a top down shooter (think 1943) and upon an enemy being destroyed I want them to randomly spawn either a power up, health, or nothing. Ideally (if it's not too crazy) I'd like to have control over, say, the likelihood of power ups that are spawned per level. I've gotten to the point where I can make the spawns seem random - but I know they're not and it bothers the crap out of me. I also fee like I'm taking the long road to get there by doing instance variables on each enemy that tick up every time the enemy is destroyed. When the count = 4, spawn object, etc. There has to be an easier way!

Any help is appreciated.
B
6
S
1
Posts: 8
Reputation: 353

Post » Sat Nov 07, 2015 8:47 am

Have you looked at using families? So into the family you could add all the things you wanted to spawn and then spawn family would pick one of them randomly.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Sat Nov 07, 2015 10:48 am

RamPackWobble wrote:Have you looked at using families? So into the family you could add all the things you wanted to spawn and then spawn family would pick one of them randomly.


We can't use families without the personal edition :(
B
14
S
2
Posts: 35
Reputation: 789

Post » Sat Nov 07, 2015 5:53 pm

@laypax
Without families you'll have to be much more verbose with your events. Like for instance setting a variable to a random integer (ex: int(random(5))) and then check it's value. For ex: if var=0 then create health, if var=1 then create powerup, ... etc
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests