How do I make an object only spawn 1 of another on creation?

Get help using Construct 2

Post » Wed Sep 07, 2016 3:15 pm

Hi, I've got a weird problem I can't figure out how to solve. My game is an arena shooter where enemies are created from a number of spawners with the logic set up basically like so: Every x seconds, create obj_enemy_00 at the spawner with y dedicated ID variable, et cetera. For just spawning a single object (the base enemy object), this works great! The trouble comes when I try to spawn an enemy with multiple parts.

Image

The way I have it set up, obj_enemy_00 has a variable called 'type' which determines what kind of enemy it is when it is spawned. The tank guy has a couple extra bits that I need to create when it spawns, but I can't figure out how. If I do this:

Image

it only creates one of each no matter how many tank guys I push out of the spawners. If I do this:

Image

it creates a scary feedback loop that, for reasons unknown to me, spawns hundreds of them per second (it does this with and without the extra "type = tankguy").

The system is relatively complex so it'd probably be easier for you to just poke around in the .capx to see if you can figure out the problem, you can download it here. I'm hoping I'm just having a brain fart and the answer is real simple.
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Wed Sep 07, 2016 4:39 pm

On created obj_enemy
Type = tank guy

Spawn obj enemy00 top spawn obj enemy01 bot

This should make it work once, per tank that is spawned. Also this is a perfect time to pin/ aquire targets
B
9
S
3
Posts: 103
Reputation: 989

Post » Wed Sep 07, 2016 4:45 pm

I always use variables when it comes to a situation like this. :mrgreen:

https://www.dropbox.com/s/9so0kijicwfih ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Thu Sep 08, 2016 12:14 am

Unfortunately neither solution works; with Aher0's, it just flat-out does not create the 01top and 01bottom objects. I think the reason for that is that the obj_enemy00s aren't created, they're spawned, which is a weird technicality? Maybe? And Gmoney's solution would work, but it's incompatible with my current spawning system.

is there a way to add the second enemy to my array system and skip spawning the enemy_00 entirely? I think that might work.

Image

Here is the event that spawns enemies from the spawners. Basically it takes whatever is at the front of the spawnlist array (pushed there in the previous step of the spawn process) and creates an obj_enemy00 with the 'type' variable set to whatever the array says. Is there a way to make it something like, say, "if spawnlist says 'tankguy', spawn obj_enemy01 instead"?
B
18
S
9
Posts: 103
Reputation: 1,817


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 40 guests