0 Favourites

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

  • 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.

    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:

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

    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.

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I always use variables when it comes to a situation like this.

  • 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.

    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"?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)