|
Post by complexity on Mar 20, 2017 21:10:26 GMT
Hello Everyone,
I have an object that i am killing, that object will spawn an "empty object" that has a script attached and that will generate loot. That loot will use a set of rules, Quantity, Quality, etc..
What is the correct way to spawn that loot using code, can i access objects that are already "pooled" and spawn them using code?? if so, how to do it.
Thank you.
|
|
|
Post by DarkTonic Dev on Mar 20, 2017 21:42:25 GMT
When something dies in CGK, you will assign what it spawns to "Death Prefab". Then, just add some code into that script that has its logic decide things in the OnSpawned method (if any is needed), because that is what gets fired by Pool Boss when it spawns.
You can spawn anything from code that's in Pool Boss with:
PoolBoss.SpawnInPool("prefabName");
|
|
|
Post by complexity on Mar 20, 2017 21:57:41 GMT
When something dies in CGK, you will assign what it spawns to "Death Prefab". Then, just add some code into that script that has its logic decide things in the OnSpawned method (if any is needed), because that is what gets fired by Pool Boss when it spawns. You can spawn anything from code that's in Pool Boss with: PoolBoss.SpawnInPool("prefabName");
so the Default "OnStart()" from unity will do be enough? it has do be "OnSpawned" from CGK?
|
|
|
Post by DarkTonic Dev on Mar 20, 2017 22:01:42 GMT
OnStart / Awake are only called once when the clone is created during Awake. They are never called again when things spawn (this is the very nature of how Pooling works, and not only our Pool Boss). Only OnSpawned is called every time something spawns out of Pool Boss. And OnDespawned is called when it despawns (and not OnDestroy - ever). Please read the Pool Boss section of the readme for more information, it's a couple pages long.
|
|