magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Nov 1, 2018 15:37:20 GMT
I'm encountering another issue with Triggered Spawners V2. I've created a spawner with a Min to Spawn and Max to Spawn value of 3, a Time to Spawn All to 3 seconds and a Delay Wave for 1 second. I've created a prefab for this spawner and put the spawner into Pool Boss. When the player destroys an item in the game, I spawn this spawner and it begins to spawn enemies as expected. However, for some reason it spawns 6 enemies instead of the maximum of 3. I've tried changing the settings for no wave delay and time to spawn all to 0, but it still happens. However, when I have the time to spawn all set to 0 then I see a set of 3 enemies spawn right away and then shortly after that the other 3 spawn.
|
|
|
Post by DarkTonic Dev on Nov 1, 2018 19:33:10 GMT
Hmm, I haven't seen that happen.
Send me an example Scene and I'll fix it. You can modify one of the Example Scenes to do the same thing.
|
|
magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Oct 5, 2019 18:49:14 GMT
I know this is old, but I finally figured out what was causing this issue and wanted to report the reason and a fix. When my Motion Controller character is running, the controller script adds 6 sphere colliders to the character. What happens is that each and every one of those colliders causes the OnTriggerEnter to fire. So the spawner ends up spawning up to the maximum preload quantity for that PoolBoss item.
I fixed this by adding a bool _triggered variable that gets set when a valid OnTriggerEnter occurs and then gets reset when a valid OnTriggerExit occurs. Then I make sure to ignore further OnTriggerEnter callbacks if _triggered = true. I think this would be something that should probably be added to the source code.
|
|
|
Post by DarkTonic Dev on Oct 6, 2019 2:05:02 GMT
Yeah, I can't add that, because sometimes that would be a desired behavior. I would say usually it is.
You could fix this without modifying CGK by making sure that the spawned spheres are in a layer or tag not in your Layer / Tag filter. Which would be a line of code inside that script right after spawning them.
|
|
magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Oct 6, 2019 14:32:22 GMT
I don't understand. How would it be a desired behavior to have an OnTriggerEnter fire more than once? The idea is that something triggers a spawner and it starts a very specific sequence of spawning with a min/max spawn and a set repeat schedule. Firing more than once disrupts that completely.
|
|
|
Post by DarkTonic Dev on Oct 6, 2019 15:01:48 GMT
Maybe in your game. Games we make set up a wave every time something enters the trigger, not just once. Maybe the wave is a "wave of 1" in our case. It still saves us having to code anything.
There are controls to disable the wave of that type after a single spawn, "Despawn this". There's also a control to stop the wave when the opposite event occurs "Stop When Trigger Exit".
As I said, you can fix it on your end by spawning the spheres in a layer not in your Layer filter. Then there spheres won't trigger it at all.
|
|
magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Oct 6, 2019 15:05:49 GMT
Not exactly. The spheres are spawned on the same game object so the layer and tag cannot be changed to something else. I'll just go with my solution since it works for my situation.
|
|
|
Post by DarkTonic Dev on Oct 6, 2019 15:18:12 GMT
Oh ok, then you could spawn them in sub-game objects. Triggers triggered by other things you are doing need to be worked around like that. I've done this type of pattern many times for "targeting triggers", "interaction triggers" etc. It does work well.
Also, you will need to re-apply the changes you made every time you update CGK since they'll get overwritten.
|
|
magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Oct 6, 2019 15:25:42 GMT
Yeah, I was aware of that, but didn't want to change their code. In either case I would have to re-apply changes every time I get an update of one of the two assets. Either yours our theirs. I think the change to yours is far simpler.
|
|
|
Post by DarkTonic Dev on Oct 6, 2019 15:33:33 GMT
Yeah, I was aware of that, but didn't want to change their code. In either case I would have to re-apply changes every time I get an update of one of the two assets. Either yours our theirs. I think the change to yours is far simpler. Ok, I thought that might have been your code.
|
|