|
Post by wa5hburn on Apr 24, 2017 13:41:42 GMT
Hi, I purchased the DTGT a while back and decided to give it a go. I have 2 questions: 1) I use Poolboss and DTGK Spawners. I have my own health manager on my spawned prefabs, when I have shot them I just "gameObject.SetActive(false); and this returns thing to the pool. Is this ok? it seems to work fine.
2) I have a gun that fires a raytrace and on hit will spawn a bullethole, the bullethole is removed after a short period time. The code for instantiating the bullethole is as follows:
GameObject cloneImpact = Instantiate(impact.GetRandomPrefab(), hit.point, Quaternion.LookRotation(hit.normal)) as GameObject;
How can I get the bulletholes from poolboss? ( I have them pooled already ). I have tried without any luck the code below:
PoolBoss.SpawnInPool(impact.GetRandomPrefab(), hit.point, Quaternion.LookRotation(hit.normal)) as GameObject;
Thanks
|
|
|
Post by DarkTonic Dev on Apr 24, 2017 16:16:05 GMT
#1 - that code will not put it back in the list of available clones to re-spawn. It also will not fire the OnDespawned method if you have one. Instead use this code: PoolBoss.Despawn(this.GetComponent<Transform>());
#2 - Pool Boss uses and returns Transforms, not Game Objects. So the code will probably look like this:
Transform spawnedTrans = PoolBoss.SpawnInPool(impact.GetRandomPrefab().GetComponent<Transform>(), hit.point, Quaternion.LookRotation(hit.normal)); // then if you need a game object. GameObject spawnedGO = spawnedTrans.GetComponent<GameObject>();
|
|