How do I Limit Spawn Time?

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I've created a game where 2 sets of enemies will be coming towards the player at random spawning times.

    I wanted there spawning rate to be more frequent to increase the difficulty of the game, so I added a Global Variable called 'SpawnTime'.

    The 'SpawnTime' will subtract from the enemy spawning rate. However I need to create a limit so that it doesn't subtract forever. Otherwise the spawn rate will eventually become '0' it meaning that it will be "every x seconds" | random(0,0)" so all the enemies will just overlap.

    Thr starting spawn rate for one of the enemies is random(5,8) so I essentially would want it to be something like random(0.5,2) when it reaches the most difficult stage.

    THANK YOU!

  • See my response to this eerily similar question from yesterday.

  • Yeah I just copied his question since its pretty much the same as mine, but It didn't work for me? not sure what I did wrong.

    Is there a different way to do this?

  • I saw someone else's post on this and I'm having the same problem. I couldn't understand the answer that they were given so I'm essentially repeating the question! Sorry

    I tried asking this question earlier today but only got referred back to the other post again which I don't understand.

    I've created a game where 2 sets of enemies will be coming towards the player at random spawning times.

    I wanted there spawning rate to be more frequent to increase the difficulty of the game, so I added a Global Variable called 'SpawnTime'.

    The 'SpawnTime' will subtract from the enemy spawning rate. However I need to create a limit so that it doesn't subtract forever. Otherwise the spawn rate will eventually become '0' it meaning that it will be "every x seconds" | random(0,0)" so all the enemies will just overlap.

    Thr starting spawn rate for one of the enemies is random(5,8) so I essentially would want it to be something like random(0.5,2) when it reaches the most difficult stage.

    THANK YOU!

    I've attached the image below with my current events page......

  • Construct has a function called min(). It takes a list of variables and returns the one that is the lowest. When you set your spawn rate value, instead using the "Add To" action, set it using the min() function. You will wind up with something like this:

    spawnTime = min(spawnTime + rateChange, maximumSpawnTime)

    spawnTime : is the current spawn rate

    rateChange: is the value you will change spawnTime by each time it changes

    maximumSpawnTime: is the highest value you want spawnTime to be set to

    Using this method, your spawn rate will never be faster than what you set as the maximum.

  • Add another condition that compares x-spawntime > 0

    This way you can't ever have less than 0.

    Going to throw out that adding 5 to speed every second can get things moving incredibly quick very fast. Like unplayable fast. Especially for mobile devices.

  • yeah i only did add 5 every second so that i could quickly see the progression of the even and whether it was working correctly.

    Tylermon how should i be coding what you said?

    interesting, i never knew about this function before. How should i code it?

    I'm sorry to sound so bad at this, its just confusing me!

  • If I understand correctly:

    Spawn rate-spawn time > 0

    Every random(spawn rate - spawn time)

    The condition you want is under system and is the compare two values.

  • davidross900 - No duplicate threads. I've merged your two threads asking the same question.

  • linkman2004 Thank you!

  • Tylermon yeah it is a bit confusing the way i've done it. I originally had the following....

    every(5,8)seconds | Create object(enemy) <----------- This is the Spawn Rate.

    Then i wanted the level to get harder by subtracting from the spawn rate time so I created the global variable SpawnTime.

    So if I add 1 to the SpawnTime and I have this subtracted from the spawn rate, then eventually the spawn rate becomes 0 which I don't want.

    I was hoping I could get it to -----------> every(0.5,1.5)seconds.......for example

    so is this how I should code it:

    Spawn rate-spawn time > 0

    and then this being the condition?................Every random(spawn rate - spawn time).................is that what you mean?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tylermon yeah it is a bit confusing the way i've done it. I originally had the following....

    every(5,8)seconds | Create object(enemy) <----------- This is the Spawn Rate.

    Then i wanted the level to get harder by subtracting from the spawn rate time so I created the global variable SpawnTime.

    So if I add 1 to the SpawnTime and I have this subtracted from the spawn rate, then eventually the spawn rate becomes 0 which I don't want.

    I was hoping I could get it to -----------> every(0.5,1.5)seconds.......for example

    so is this how I should code it:

    Spawn rate-spawn time > 0

    and then this being the condition?................Every random(spawn rate - spawn time).................is that what you mean?

  • sorry about the duplicate message, scirra was playing up a little

  • Yeah. Basically whatever you are wanting to be greater than 0 should be in that compare statement. If you want it greater than 1.5 or something you could change 0 to anything you want.

    Just make sure you have an else statement that will basically do your hardest difficulty. This way when that compare condition eventually fails the game still continues doing what you expect.

  • It looks like you might be going with Tyler's method but, to answer your question:

    [quote:33afw4ed]interesting, i never knew about this function before. How should i code it?

    /b]

    You code it exactly as I typed it:

    [quote:33afw4ed]min(spawnTime + rateChange, maximumSpawnTime)

    Replace rateChange with the amount you want to change the variable with. In your picture you are just adding 1 so, replace rateChange in the above with 1. Replace maximumSpawnTime with the maximum you want the spawnTime to be. If you don't want the spawnTime to be higher than 5, replace maximumSpawnTime with 5. Other than that, you can copy and past this equation directly into where you are setting the variable. Again, use the "Set Variable" method, not the "Add To" variable method.

    I hope that clears things up for you and good luck with your project.

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