cris
New Member
Posts: 9
Posts: 9
|
Post by cris on May 22, 2017 8:54:52 GMT
Hi there,
I want to use Pool Boss programatically since I instantiate a lot of stuff in runtime depending on the stage and level of the game. I've seen that I can call PoolBoss.CreateNewPoolItem to create a new pool and give it a name ID. However I would like to know what function I can use to retrieve (or spawn, aka enable an item) the next available (disabled) item in the pool of a specific name previously defined. So far I've seen I can spawn an item using either the transform of the prefab that was used to create the pool or the name of the instance, but I would like to simple access a pool and get any available item.
Any ideas?
Many thanks in advance.
|
|
|
Post by DarkTonic Dev on May 22, 2017 15:58:15 GMT
I think you're looking for these:
To just grab the next available item:
var nextItem = PoolBoss.NextPoolItemToSpawn(string itemName); // or pass the Transform that has that name
You then can use that variable to spawn it:
PoolBoss.SpawnInPool(nextItem, Vector3.Zero, Quaternion.Identity);
Or just spawn it directly without caring about "next item":
PoolBoss.SpawnInPool("item name", Vector3.Zero, Quaternion.Identity);
|
|
cris
New Member
Posts: 9
Posts: 9
|
Post by cris on May 23, 2017 9:33:15 GMT
Many thanks for your reply, I think I phrased wrong my question. In the points you mention, I can access the instanced either using the name of the instance or the transform of the original prefab. So this is great so far.
However the question is how I access items in categories. For example I want to create a category to store a type of enemies (i.e warriors) and another category to store a different type of enemies (i.e. archers), so I use the following code: PoolBoss.CreateNewPoolItem(warrior_prefab, 10, false, 50, false, "Enemies_Warriors"); PoolBoss.CreateNewPoolItem(archer_prefab, 10, false, 50, false, "Enemies_Archers");
Then I would like to do something like: var nextItem = PoolBoss.NextPoolItemToSpawn("Enemies_Warriors");
or: PoolBoss.SpawnInPool("Enemies_Archers", Vector3.Zero, Quaternion.Identity);
As far as I understood the 'categories' are mean to be used to structure instances, but maybe I misunderstood this concept and categories are only for debug purposes through the inspector? (since I cannot find any function that accepts them as argument other than the CreateNewPoolItem.
Many thanks again for your help.
|
|
|
Post by DarkTonic Dev on May 23, 2017 15:41:27 GMT
Correct. They are for visual ease of finding things only. In thr Inspector. There is a DespawnAllOfCategory call as well.
If you upgrade to Core Gamekit, we have another feature called Prefab Pools that allows weighted randomization of different prefabs. Maybe that's what you're looking for.
|
|
cris
New Member
Posts: 9
Posts: 9
|
Post by cris on May 24, 2017 10:44:16 GMT
I see, many thanks for clarifying. I've managed to integrate it in the project by referencing prefabs, should be ok for now I've already upgraded to the game kit, just I wanted to implement the pooling system first, but the spawning features look very interesting as well, I´ll be looking into those in the future. Many thanks for your help!
|
|
|
Post by DarkTonic Dev on May 24, 2017 15:59:42 GMT
Excellent. The Killable script is also extremely useful foe enemies, weapons and pickups.
|
|