How do I Limit Spawn Time?

Get help using Construct 2

Post » Tue Mar 24, 2015 2:03 pm

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!

Image
B
3
Posts: 36
Reputation: 253

Post » Tue Mar 24, 2015 2:08 pm

See my response to this eerily similar question from yesterday.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Tue Mar 24, 2015 2:36 pm

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?
B
3
Posts: 36
Reputation: 253

Post » Tue Mar 24, 2015 6:31 pm

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

Image
B
3
Posts: 36
Reputation: 253

Post » Tue Mar 24, 2015 6:47 pm

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.
B
40
S
12
G
11
Posts: 331
Reputation: 7,752

Post » Tue Mar 24, 2015 7:13 pm

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.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Tue Mar 24, 2015 7:43 pm

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?

@fragfather 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!
B
3
Posts: 36
Reputation: 253

Post » Tue Mar 24, 2015 7:48 pm

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.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Tue Mar 24, 2015 7:51 pm

@davidross900 - No duplicate threads. I've merged your two threads asking the same question.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Tue Mar 24, 2015 8:07 pm

@linkman2004 Thank you!
B
3
Posts: 36
Reputation: 253

Next

Return to How do I....?

Who is online

Users browsing this forum: NN81 and 45 guests