How do I make 'spawn zones' have their own individual spawn count?

0 favourites
  • 10 posts
From the Asset Store
Be quick and count the cards and choose the right number!
  • My goal that I wish to accomplish is that I have several spawn zones across the map that each one can only spawn 3 enemies. After enemies are killed inside these spawn zone a new enemy will be spawned after say 30 seconds to replace them.

    However I've run into a snag. I got most of the basics working however when a enemy at another spawn location gets killed all the other spawn zones will spawn a new enemy if their timer is ready.

    I know its a issue with how I set the "spawn count" variable but I'm not sure how to fix it.

    Here's a demo I cooked up to to show what I mean

    https://drive.google.com/file/d/13DdHPzXP-SJOMUyKwhxLM8eBOS3p8bCi/view?usp=sharing

  • It's because the enemies don't relate to any particular spawn point. When you kill an enemy you say to reduce the spawn point variable by 1 for all spawn points. What you can do is have an instance variable on the enemies that upon being created is set to the spawn point UID from where it came. Then an enemy is related to a spawn point. Then you can say enemy on destroyed with another condition, enemy.variable=spawnzone.UID : reduce spawn zone count.

  • Didn't completely fix the problem. Although it now check whether the enemies did come from their unique spawn zone it still Adds and Subtracts from a shared 'spawncount' variable.

    My Code

    In this examples case i killed all the enemies in the other spawn zones and left one alone. End result was the the spared zone ended up hogging all the spawn count.

    In this example I got the spawn count to 2 and then all the spawn zone spawn in a enemy at once resulting in 6 enemies(one spawn on top of another that's why you cant see it.)

  • Those events need changing a bit. Get rid of the on created events. On the top event where you spawn the object here you should set the enemy variable to spawnzone.UID and also add 1 to the spawn zone variable. Also you need to get used to pick conditions with objects not System. Use the object and use compare variable.

    To explain the problem in more detail - when you use enemy on created : set variable to spawnpoint.UID again you haven't picked a spawnpoint. It doesn't assume the one it spawned from when it is a new event. You should try and do as much as possible in the event where the instances were picked.

  • The spawn count limit is working correctly for the upper/top spawn zone. The other zones not so much

    My Code

    I killed a whole lot of enemies in the top zone and all the other zones started spawning enemies.

    and when I killed all the enemies in the other zones but nothing spawned

    And with the pick conditions. I was just trying out the system ones because I wanted to see if they would do anything different and also seeing if the it were possible to put the self thingy in their.

  • On destroyed should be instead of the system condition pick the spawn zone and say spawnzone.UID = enemy.var

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It took me a couple of minutes but I found what I assume what you were talking about.

    Everything seems to work fine now. Thanks for pick of your brain.

  • Nice :) looks good. I would make a habit out of picking with the object and not go for those solo system conditions.

  • Do you still have the code? i am currently try to learn to make spawn zones, and its really hard to find the answers, a screenshot would be enough :)

    if you dont have it anymore its ok :)

    Thanks in advance

  • Hi, the screenshot is in the post above yours? If you are looking for something different though I would make a new post.

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