|
Post by soundmartell on Jan 24, 2017 0:55:59 GMT
Hello, I have an Object "X" with the Triggerd Spawner script with the Enable Event, the object is active so it is spawned as soon as start the game. I have a Wave "Y" and I need to despawn the Object "X" as soon as the wave "Y" finish. I have been trying with customs Events and others but I am very new with Core GameKit, I will appreciated any help, Thank you.
|
|
|
Post by DarkTonic Dev on Jan 24, 2017 1:16:20 GMT
You could do it like this (custom events yep).
1) Add a Triggered Spawner component to your Object X prefab. 2) In the Event to Activate list, choose Custom Event. 3) Select the Custom Event you've created and fired in Wave Completion Custom Events. 4) Tick the "despawn this" checkbox in the settings for Custom Event you added in step 2.
Either that or use a LevelSettingsListener and add code to the WaveEnded method, like PoolBoss.DespawnAllOfPrefab(); No Custom Event needed this way, but yes you have to type of line of code or 2.
|
|
|
Post by soundmartell on Jan 24, 2017 1:56:17 GMT
You could do it like this (custom events yep). 1) Add a Triggered Spawner component to your Object X prefab. 2) In the Event to Activate list, choose Custom Event. 3) Select the Custom Event you've created and fired in Wave Completion Custom Events. 4) Tick the "despawn this" checkbox in the settings for Custom Event you added in step 2. Either that or use a LevelSettingsListener and add code to the WaveEnded method, like PoolBoss.DespawnAllOfPrefab(); No Custom Event needed this way, but yes you have to type of line of code or 2. Thank you for answering. Its work but as I has the Object X Triggered with Enable it is spawned again. Is it any way to Spawn Object X when the Wave Star? I can't see a Custom event for a Wave star only for Wave Completion. Thank you.
|
|
|
Post by DarkTonic Dev on Jan 24, 2017 2:19:03 GMT
That is correct, if you use LevelSettingsLisener there are events for both WaveStarted and WaveEnded, where you can add any code you like.
I don't understand what you mean about why the first method doesn't work though. Maybe some screen shots would help? Why does it spawn again? Show me the setting that causes this.
|
|
|
Post by soundmartell on Jan 24, 2017 3:13:53 GMT
Ok, The problem is the Object was not in the pool so the transform couldn't despawn.
Could you help me to use the LevelSettingsLisener events for both WaveStarted and WaveEnded?
Thank you.
|
|
|
Post by DarkTonic Dev on Jan 24, 2017 5:47:41 GMT
Using Listeners is pretty easy, steps are in the Readme under the Listeners section.
1) Create a subclass of whatever Listener you want to use (this is so that you can have more than one with different code). So, create subclass of LevelSettingsListener.cs 2) Override one of more methods by adding code to them (they are all empty). Add code to WaveEnded: PoolBoss.DespawnAllOfPrefab("prefabName); 3) To actually hook up the Listener, place your subclass you created as a component in step 1 on the same Game Object as the thing it's Listening to, and it will auto-hook up (so add it to LevelSettings game object). 4) If you prefer to add the Listener elsewhere, you will need to go to the Listener field of what you want to listen to and drag the game object that has the Listener into that field to hook it up.
-B
|
|
|
Post by soundmartell on Jan 24, 2017 18:11:54 GMT
Thank you for your help and support. It work. Regards.
|
|
|
Post by DarkTonic Dev on Jan 24, 2017 19:07:45 GMT
No problem.
|
|