bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on Dec 12, 2022 15:50:52 GMT
I have 3 enemy prefabs (many more to come).
2 created from scratch (but mostly same components), and the 3rd was created as a duplicate of an existing enemy then modified and now has at least one different component. They all have several of the same components but different models/settings etc.
I added all prefabs to Poolboss. I have an in-scene prefab selector that gets the prefab based on it's enemy type, then spawns that prefab from PB.
The problem is 2 of the enemy types are spawned as the same prefab. Like PB is confused about which prefab to spawn.
I have since tried unpacking prefabs, creating original prefabs from those, re-linking everything in my prefab selector and in PB and it still treats 2 of my enemy prefabs as the same spawn.
I trace code and my prefab selector is correct showing me different prefabs based on enemy type, but PB still spawns the same prefab for 2 different prefab objects.
What needs to be different in prefabs to make sure PB will spawn the correct item?
Code is pretty simple, get desired prefab from GameDataManager, pass that to PB. LG_Enemy enemyPrefab = LG_GameDataManager.Instance.EnemyPrefabs.Where(x => x.enemyType == subwaveEnemyDefinition.enemyType).FirstOrDefault(); Transform spawnItem = PoolBoss.Spawn(enemyPrefab.transform, nextSpawnPoint.position, nextSpawnPoint.rotation, null); Stepping through the code above, enemyPrefab is the correct prefab, but spawnItem is the wrong object. 
|
|
|
Post by DarkTonic Dev on Dec 13, 2022 1:31:39 GMT
Pool Boss spawns by name only. You may be sending it the wrong name.
That seems pretty weird, you'll need to send me a scene that reproduces the problem. Not able to reproduce on my end.
Thanks, -Brian
|
|
bbjones
New Member
Posts: 19
Posts: 19
|
Post by bbjones on Dec 13, 2022 4:31:08 GMT
Pool Boss spawns by name only. You may be sending it the wrong name. That seems pretty weird, you'll need to send me a scene that reproduces the problem. Not able to reproduce on my end. Thanks, -Brian Yes that seems to be the issue.
When adding a prefab to PB it automatically adds the PoolableInfo component with the name of the prefab as a string. If you duplicate that prefab you then have the same string value on both PoolableInfo components so PB is just doing what it's told.
Perhaps PB can show you the string name it uses for items in the inspector along with the prefab name? Would be much easier to identify problems like that.
Or some validation check that tells you if PB has more than one entry of the same PoolableInfo string value.
|
|
|
Post by DarkTonic Dev on Dec 13, 2022 16:00:34 GMT
You can reset the PoolableInfo component and it will grab and cache the correct name.
|
|