Setting spawn limit in endless survival game.
![zefrof](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I have a set of attributes (wavenumber, badguys, and start round) and a set of rules:
![image](https://sphotos.xx.fbcdn.net/hphotos-snc7/602285_2263320400507_1847614266_n.jpg)
![image](https://sphotos.xx.fbcdn.net/hphotos-ash3/559197_2263319800492_343568754_n.jpg)
When an enemy is killed it subtracts 1 from bad guys. When bad guys equals 0 it adds one the the wave number and changes bad guys to 2*wavenumber.
![image](https://sphotos.xx.fbcdn.net/hphotos-ash4/402952_2263327000672_235015022_n.jpg)
Currently it's set to spawn every 3 seconds. I want it to only spawn the number of bad guys needed to beat a wave. I've tried this but it wouldn't spawn enemies on wave 2.
![image](https://sphotos.xx.fbcdn.net/hphotos-ash3/548224_2263336040898_470758897_n.jpg)
Is it as simple as changing the conditions for spawning or do I need to do something else?
![image](https://sphotos.xx.fbcdn.net/hphotos-snc7/602285_2263320400507_1847614266_n.jpg)
![image](https://sphotos.xx.fbcdn.net/hphotos-ash3/559197_2263319800492_343568754_n.jpg)
When an enemy is killed it subtracts 1 from bad guys. When bad guys equals 0 it adds one the the wave number and changes bad guys to 2*wavenumber.
![image](https://sphotos.xx.fbcdn.net/hphotos-ash4/402952_2263327000672_235015022_n.jpg)
Currently it's set to spawn every 3 seconds. I want it to only spawn the number of bad guys needed to beat a wave. I've tried this but it wouldn't spawn enemies on wave 2.
![image](https://sphotos.xx.fbcdn.net/hphotos-ash3/548224_2263336040898_470758897_n.jpg)
Is it as simple as changing the conditions for spawning or do I need to do something else?
Best Answers
-
MotherHoose Posts: 2,456
@zefrof … problem may be:
changeAttribute: game.waveNumber is not changed at correct time
on the Rule: when
Attribute: game.startRound is true
Attribute: game.BadGuys = 0
-changeAttribute: game.waveNumber To: game.waveNumber+1
-changeAttribute: game.startRound To: false
on the Rule: when
Attribute: game.startRound is false
-changeAttribute: game.BadGuys To: 2*waveNumber
-changeAttribute: game.startRound To: trueMH
-
tatiang Posts: 11,949
Try adding a buffer to the For timer so that it says 2*game.wavenumber+0.5, as I suggested above. In testing, that worked for me.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
Another way to limit bad guys would be to have each bad guy change attribute game.badguyCount to game.badguyCount+1 and then add a condition to your Spawn Actor behavior that says When game.badguyCount<game.badguys.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
To spawn correct amount of bad guys, do something like this:
1. Every 3 seconds:
- Change attribute [StartSpawn] = 1
2. If [BadGuyCount] > 0:
(Inside of Rule 2)
2a. If [StartSpawn] = 1:
(Inside of Rule 2a)
2a-a. Every 0 seconds:
- Spawn Bad Guy
- Change Attribute [BadGuyCount] to [BadGuyCount]-1
Otherwise (For Rule 2):
Change Attribute [StartSpawn] = 0
I say something like this because I it may need to be tinkered with.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
attribute: game.startround is true
attribute: game.badguys = 2*game.wavenumber
timer:
for 2*game.wavenumber
every 1 sec spawn enemy
It will run the first wave fine and even start the second wave now, but the second wave only spawns 3 enemies when it needs 4 to finish the wave. Anybody think of what I can do to fix it?