|
Post by milliemag on Apr 29, 2016 5:09:02 GMT
Hey there,
Great Unity Asset. I'm really excited to get the hang of it for my 2D space shooter. I'm trying to get my player to shoot an endless amount of bullets (once every 0.5 seconds), but I'm experiencing a bit of trouble. Perhaps you can clear things up for me. I've gone through all the video tutorials and I have a triggered spawner on my ship and on the childed spawn points. There's also a Killable script attached, which works just fine with despawning after hitting an enemy. I'm trying to get the player bullets to add back to the pool boss and keep them shooting in an endless wave at the same firing rate, but after my first wave of enemies comes and goes, the player bullets stop. The enemies are set up as global waves and I tried to add my player bullet to the pool boss with a quantity of 20 bullets preloaded, which should be more than enough. But I'm not sure how to make them despawn and go back to the prefab pool when they go off screen. The Timed Despawner isn't despawning after the 2 second time limit I set on it, and the Invisible Event in Triggered Despawner doesn't have any options to click on. Which should I be using to make my steady barrage of bullets despawn once off the screen and add back to the prefab pool and then continue spawning in an endless wave?
Thanks,
MillieMag
|
|
|
Post by DarkTonic Dev on Apr 29, 2016 5:30:48 GMT
Timed Despawner definitely works. It may be going back into Pool Boss as a differently named item. When you attempt to spawn it again when none are left, you should get a warning in the Console telling you what's wrong. Or look at the Pool Boss game object during runtime when that happens.
But ultimately it's easiest to make them despawn when offscreen with the checkbox in Killable section "Despawn and Death Triggers" called "Invisible Event". The renderer must be on the same game object as the Killable though.
I'd be interested to know why the Timed Despawner isn't working if you can report back though.
|
|
|
Post by milliemag on Apr 30, 2016 0:30:04 GMT
Thanks so much! The killable script worked for despawning and adding back to the pool boss once the player's bullet was off the screen. I don't know how I overlooked that.
I'm not sure why the Time Despawner didn't work on my player bullet prefab. I tried it on the player gameObject itself and that worked perfectly. So, I have to assume I didn't assign it to the proper elements or something. Did it need to be on the player and the bullet in the same way that both the player and the child spawner needed the triggered spawner perhaps?
|
|
|
Post by DarkTonic Dev on Apr 30, 2016 2:15:39 GMT
You probably overlooked it because the Killable script has about 100 options TimedDespawner has nothing to really do except set the timer...so I'm not sure how it didn't work unless you unchecked "start time on awake".
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jun 7, 2016 11:48:29 GMT
Hi,
i've got the similar problem, my bullets are flying offscreen and killing baddies, which is a bad thing. Timed despawn doesn't solve the problem because i need to set it to at least the horizontal screen length and if i'm close to the right side of the screen (it's a left-to-right sidescrolling shooter) they will go too far and kill enemies again.
Now, i've tried enabling Ignore Offscreen Hits on the enemy's killable (2d sprite) but it has no effect. I've also tried enabling Invisible Event on bullet's killable, it doesn't work. Not Visible Too Long doesn't work either. I've put Killable Child Visibility script on the bullet and assigning its killable, but that doesn't work too. Any more ideas?
|
|
|
Post by DarkTonic Dev on Jun 7, 2016 15:27:34 GMT
Killable child visibility has to go on the sub game object that has the renderer. And then you drag the parent Killable into its Inspector to connect them. Turn on logging for the Killable as well to read more clues from the console.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jun 7, 2016 15:40:48 GMT
I don't quite get it, bullet prefab already has the sprite renderer. Do i need to create an empty child object that will hold only the killable child visibility script?
Do you think that maybe nesting the killable subclasses OnDespawn method inside OnBecameInvisible would do the trick?
|
|
|
Post by DarkTonic Dev on Jun 7, 2016 16:27:44 GMT
Then you don't need the "child" script at all. Make sure the game object isn't visible in Scene view during your testing because OnInvisible won't fire. It's a weird Unity quirk.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jun 7, 2016 16:43:12 GMT
Damn, most of the problems come from unity itself, i was watching the scene view zoomed out and wondering what the hell is going on. I'll test it and report back, thank you.
|
|
|
Post by DarkTonic Dev on Jun 7, 2016 17:27:08 GMT
No problem.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Jun 12, 2016 19:27:13 GMT
Just to report back, works fine, thanks again
|
|
|
Post by DarkTonic Dev on Jun 12, 2016 19:45:32 GMT
Awesome! You're welcome.
|
|
|
Post by milliemag on Jun 17, 2016 15:06:13 GMT
Quick question here. I was wondering if there was a way to just use Pool Boss for my game so that I can do Object Pooling on my waves of enemies. There's a lot to Core Gamekit and it's kind of overwhelming my brain looking through all the documentation. Plus, since I'm trying to incorporate Playmaker, I was hoping to find a simple object pooling solution that would prevent my current brain overload. Essentially, I just want to spawn a few waves of enemies every few seconds, and then stop after roughly 3 minutes to bring in a boss battle (I already have a script for the creating enemy waves, but it only seems to work if I'm using regular instantiate and destroy calls). But with everyone else's object pooling assets I've used before, I always end up getting an IndexOutOfArrayException, no matter how many prefabs I pool in advance. Once the code has gone through the last enemy of its type in the pool and despawned everything back to the pool, it always throws an exception (and it seems like it's trying to clone the clone prefab or something). Either way, the enemy always ends up back at the spawn point but no longer moves, and a bunch of enemies of that type keep on piling on top of each other while I'm getting the same error over and over. I heard something about resetting the enemy prefab some kind of way, just before despawning, but I have no clue how to do that. Your thoughts?
MillieMag
|
|
|
Post by DarkTonic Dev on Jun 17, 2016 16:01:13 GMT
I doubt PoolBoss will magically work if you've tried other pooling plugins already. You may have something in one of your scripts on the things you're spawning that's causing the problem. Or in your FSM. Let us know if PoolBoss saves the day though!
Yes, you can use only PoolBoss. Give it a try. There are 2 methods you can add to a script on the objects you are pooling (requires coding) to reset any state needed. They are the OnSpawned and OnDespawned methods. For example, we have code in OnSpawned to pick a random material from a list of 4 that are assigned in the script. What this does is help spawn a random colored car. Each time the car respawns it picks another color, since the code is in OnSpawned. If the code were in Awake or Start, respawns would never pick a new color and you'd be stuch with the initial color pick. Both are valid, it just depends what you want to do. Sometimes (a lot of the time) OnSpawned and resetting state is not needed.
You can always come back later and use more features if you want. Core GameKit is pretty complicated, and also pretty powerful.
|
|