chane
New Member
Posts: 10
Posts: 10
|
Post by chane on May 20, 2014 5:36:29 GMT
I have a Triggered Spawner setup to start spawning enemies when the player becomes visible. I could have sworn in a previous version that when I moved off screen the enemies would stop spawning until I moved back on screen. Here was the previous video showing the behavior, and I am pretty sure I didn't change it on my side. www.youtube.com/watch?v=EsnR4hAH4E4In case I am smoking crack, what is the best way to create this behavior now? I don't want to despawn the spawner until I am much further away from it in the world, but having enemies shoot bullets from off screen is the gold rule of suck. Thanks, Chane
|
|
|
Post by DarkTonic Dev on May 20, 2014 6:01:11 GMT
I'm not sure how you managed to do that in the video. Until tonight there was no way to prematurely end a wave in a Triggered Spawner without disabling the script entirely or despawning / destroying it. I just added an "EndWave" method to Triggered Spawner, that takes an EventType parameter so you can tell it which wave to end (Visible for you). Probably the easiest way to do it would be to subclass the Killable class (I assume you're using it already for combat), override the BecameInvisible event and call EndWave. Like this.
public override void BecameInvisible() { base.BecameInvisible();
var spawner = this.GetComponent<TriggeredSpawner>(); if (spawner != null ) { spawner.EndWave(TriggeredSpawner.EventType.Visible); } }
I'm submitting the version with EndWave tonight and it will be live within the hour. It would be easier to subclass TriggeredSpawner, but I haven't made all the right methods public yet.
|
|
chane
New Member
Posts: 10
Posts: 10
|
Post by chane on May 20, 2014 6:33:59 GMT
Awesome, thanks!
Mystery solved. I created that behavior by using the Invisible Event and passing it an invisible prefab with the intention of cleaning it up later... A bit gross, but I'm still learning the best way to script your package without scripting with C#...
I'll grab the updated version and give your changes a try.
|
|
|
Post by DarkTonic Dev on May 20, 2014 6:40:19 GMT
Starting an invisible wave doesn't halt the visible wave does it? It's not supposed to.
|
|
chane
New Member
Posts: 10
Posts: 10
|
Post by chane on May 20, 2014 6:42:51 GMT
|
|
|
Post by DarkTonic Dev on May 20, 2014 6:58:31 GMT
That's right, you can spawn zero. What I'm saying is just because an invisible wave is starting doesn't mean the visible wave will/should stop. You can actually have all 17 different events in a Triggered spawner spawning their waves at the same time.
Anyway, I'll see if I can add a checkbox to the visible event that says "stop wave when invisible". And other obvious ones for opposites (trigger enter / exit).
|
|
chane
New Member
Posts: 10
Posts: 10
|
Post by chane on May 20, 2014 7:48:40 GMT
I'm not doing anything special for spawning the prefab. I have a simple Play Maker script attached to a transform and a box collider. On the triggered event I call the Core Game Kit Pool Boss Spawn action to spawn an enemy object with a Trigger Spawner configured above. Did a quick test: - Same setup as image reference - Enabled the OnSpawned Event Once the enemy object spawns both events spawn their waves endlessly. If the player is no longer visible only the OnSpawned event continues. If the player becomes visible again both waves continue. Anyway, just wanted to say thanks, playing with this stuff is fun, and I'm pretty sure you don't sleep. Here is an updated test project video if you want a peek (it's always fun to see people using your stuff, well at least it is for me, and man I have a long way to go): www.youtube.com/watch?v=UjwLxozwaUI&feature=youtu.be
|
|
|
Post by DarkTonic Dev on May 20, 2014 16:16:45 GMT
Your game looks cool (I respect old school style games). I don't sleep much, you're right 
|
|