Hello everyone, am having issues integrating pool boss(an object pooling asset) with ork framework. Am trying to pool my combatant spawning and hit box spawning(just a gameobject with damage dealer, spawned when a combatant uses an ability). But i have noticed that when i use combatant spawner area to spawn combatants, only one of the combatants hunts the player, others stays idle. Again the hit box is never activated(it stays deactivated) in the pool when an ability is used by the player, so no damage is done to the enemy combatant. Am not sure if i provided enough information to tackle this problem, but any suggestion will be appreciated. Below is my wrapper code.
using System.Collections;
using DarkTonic.PoolBoss;
using UnityEngine;
using ORKFramework;
// ReSharper disable once CheckNamespace
public static class GOWrapper {
// instantiate
public static GameObject Instantiate(GameObject prefab) {
return Instantiate(prefab, Vector3.zero, Quaternion.identity);
}
public static GameObject Instantiate(GameObject prefab, Vector3 position, Quaternion rotation) {
var trans = GetTransformFromGameObject(prefab);
if (trans == null) {
return null;
}
var spawned = PoolBoss.SpawnInPool(trans, position, rotation);
return GetGameObjectFromTransform(spawned);
}
// destroy
public static void Destroy(GameObject gameObject) {
var deadTrans = GetTransformFromGameObject(gameObject);
if (deadTrans == null) {
return;
}
PoolBoss.Despawn(deadTrans);
}
public static void Destroy(GameObject gameObject, float time) {
ORK.StartCoroutine(DestroyAfterWait(gameObject, time));
Destroy(gameObject);
}
#region Helper Methods
private static IEnumerator DestroyAfterWait(GameObject gameObject, float time) {
yield return new WaitForSeconds(time);
Destroy(gameObject);
}
private static Transform GetTransformFromGameObject(GameObject go) {
if (go == null) {
return null;
}
return go.GetComponent();
}
private static GameObject GetGameObjectFromTransform(Transform trans) {
if (trans == null) {
return null;
}
return trans.gameObject;
}
#endregion}
I'll look into it.
Edit: Will be changed in the next ORK update to make this compatible.
However, there's a general issue with pool boss, because the pooled objects are parented to the pool boss game object and not unmounted when 'spawned'.
To fix this, add this line to the GetGameObjectFromTransform function before returning:
trans.parent = null;
Or use the plugin available on ORK's website, I've just updated it with that fix :)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!