# Creating a Random Mob Spawner in the Free Ed?

Get help using Construct 2

### » Sat Feb 09, 2013 4:16 am

Add a condition to the one that checks distance. If you want it to spawn say...15% of the time, you'd use something like Compare Two Values-> random(0,100) <= 15.

Another thing to consider: This action is going to spawn everytime you run through the loop, so if that spawner object stays within the spawn distance you put in there, it's going to start popping out mobs at a high rate. The random statement I just mentioned will address that. You might want to add in one more condition to limit the number of times it can fire over a given period of time, like Every 1 second or something of that type.

(just speaking from experience there)
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

### » Sat Feb 09, 2013 4:24 am

[QUOTE=theubie] Add a condition to the one that checks distance. If you want it to spawn say...15% of the time, you'd use something like Compare Two Values-> random(0,100) <= 15.

Another thing to consider: This action is going to spawn everytime you run through the loop, so if that spawner object stays within the spawn distance you put in there, it's going to start popping out mobs at a high rate. The random statement I just mentioned will address that. You might want to add in one more condition to limit the number of times it can fire over a given period of time, like Every 1 second or something of that type.

(just speaking from experience there)[/QUOTE]

So add a second condition to do say random(0,100) <= 20 (for 20% spawn chance) and then a third condition that checks every 3 seconds? What would that even look like? 0_o
MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

### » Sat Feb 09, 2013 4:51 am

Something like this

B
26
S
8
G
3
Posts: 210
Reputation: 5,973

### » Sat Feb 09, 2013 6:13 am

[QUOTE=theubie] Something like this

[/QUOTE]

I figured something like that. Thanks sir!

Next on my list is to figure out how to make a mob stay at a distance from a player while still following them, shooting bullets at them, and moving around in a random pattern.
MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

### » Sat Feb 09, 2013 10:12 pm

So I am having an issue where it doesnt seem that anything wants to trigger...

Here is what I have:

No matter what (even without the random and the every second statements) the spawner is doing nothing...
MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

### » Sat Feb 09, 2013 10:29 pm

Check the coordinates for Player.X,Y and Spawner.X,Y and make sure you've got the right objects selected.

Disable all three of the requirements, then enable them one by one until it stops working and we can go from there.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

### » Sat Feb 09, 2013 10:38 pm

Nevermind just solved it. I ended up just having it based on whether or not the Spawner was "Visable On Screen" which apparently amounts to any part of it (Even the TINIEST part) being in the viewable area.

MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

### » Sun Feb 10, 2013 12:02 am

Yes, that works as well.

I had figured the problem is that you might have more than one spawner (i.e. you have a spawner off layout that you placed at design time, then you spawned another one at run time.) and it was evaluating based on the first spawner, which probably wasn't moving.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

### » Sun Feb 10, 2013 2:02 am

[QUOTE=theubie] Yes, that works as well.

I had figured the problem is that you might have more than one spawner (i.e. you have a spawner off layout that you placed at design time, then you spawned another one at run time.) and it was evaluating based on the first spawner, which probably wasn't moving.[/QUOTE]

How would ya fix that?
MOO
B
14
S
4
G
4
Posts: 53
Reputation: 3,862

Previous