How do I spawn enemies at random (accessible) points?

Get help using Construct 2

Post » Sat Mar 12, 2016 9:47 pm

For a platformer, what would be a good way to go about this? Of course, I don't want them to pop in within the player's vision or in places they can't even get to.
B
8
S
1
Posts: 60
Reputation: 574

Post » Sun Mar 13, 2016 2:04 am

Also, preferrably still in close proximity to the player.
B
8
S
1
Posts: 60
Reputation: 574

Post » Sun Mar 13, 2016 1:04 pm

No one?
B
8
S
1
Posts: 60
Reputation: 574

Post » Sun Mar 13, 2016 7:43 pm

Let's say your object that your spawning is named, "Enemy". And your trying to spawn him every 5 seconds. I know that's not what your doing, but you didn't provide enough details.

So try putting this Event,
Every 5 seconds > System create object, Enemy.

Put what layer you want the Enemy on.
For the coordinates of spawning use, X:random(width of your layout)
Y:random(height of your layout)

So Every 5 Seconds a "Enemy" spawns at a random spot anywhere on the layout.

-But your question is what if he spawns in a block or somewhere he can't move?

To solve that, use this.
Enemy is overlapping Platform>Destroy Enemy
>Create Object "Enemy" on layer 0 (random(width of your layout)) (random(height of your layout))

Basically when he's created and he is somewhere he is not supposed to be, he will be destroyed and placed in a new spot, if this keeps happening he will keep spawning until there is somewhere "spawn able."

This is a bad example but it can be worked with, if it is not fitting your game tweak it the way you want it or just not use it.
I don't think I could ever stab someone, I mean, let's be honest. I can barely get the straw into a Capri Sun.
B
26
S
10
G
7
Posts: 91
Reputation: 6,420

Post » Sun Mar 13, 2016 8:50 pm

Potato23 wrote:Let's say your object that your spawning is named, "Enemy". And your trying to spawn him every 5 seconds. I know that's not what your doing, but you didn't provide enough details.

So try putting this Event,
Every 5 seconds > System create object, Enemy.

Put what layer you want the Enemy on.
For the coordinates of spawning use, X:random(width of your layout)
Y:random(height of your layout)

So Every 5 Seconds a "Enemy" spawns at a random spot anywhere on the layout.

-But your question is what if he spawns in a block or somewhere he can't move?

To solve that, use this.
Enemy is overlapping Platform>Destroy Enemy
>Create Object "Enemy" on layer 0 (random(width of your layout)) (random(height of your layout))

Basically when he's created and he is somewhere he is not supposed to be, he will be destroyed and placed in a new spot, if this keeps happening he will keep spawning until there is somewhere "spawn able."

This is a bad example but it can be worked with, if it is not fitting your game tweak it the way you want it or just not use it.

I did kind of figure something out like this, but I want it so that enemies spawn relatively close to the player but not within their view.
B
8
S
1
Posts: 60
Reputation: 574

Post » Sun Mar 13, 2016 8:54 pm

You could make invisible spawn points and have a condition that prevents them from spawning enemies if they are on screen. A really cheapo way of making them spawn if they're in a specific distance would be to maybe attach a big invisible shadow to the player so you could have "If spawner is overlapping shadow and not on-screen" added to its conditions.
B
5
Posts: 15
Reputation: 505

Post » Sun Mar 13, 2016 10:19 pm

viewtifulrexx wrote:You could make invisible spawn points and have a condition that prevents them from spawning enemies if they are on screen. A really cheapo way of making them spawn if they're in a specific distance would be to maybe attach a big invisible shadow to the player so you could have "If spawner is overlapping shadow and not on-screen" added to its conditions.

That is a better way, XD!
I don't think I could ever stab someone, I mean, let's be honest. I can barely get the straw into a Capri Sun.
B
26
S
10
G
7
Posts: 91
Reputation: 6,420


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, kellehk, KSLR, R0J0hound, tarek2 and 35 guests