edited February 16 in ORK Scripting
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
}
Post edited by henkesky1 on
  • @gamingislove is there any suggestion on how to fix this problem for now?
  • edited February 20
    Currently not - it's most likely that some things don't get reinitialiized due to being disabled and reused instead of destroyed.

    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 :)
    Post edited by gamingislove on
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • edited February 21
    @gamingislove thanks, but there is a little issue. The combatants gameobjects are never pooled. They are not even destroyed when the combatants dies. I also notice a pile of _DisplayText gameobject(probably from the battle text) which are not destroyed in the hierachy view of unity editor, with console messages The Transform '_DisplayText' passed to Despawn is not in Pool Boss. Not despawning. Can this be solved with any modification to the ORKPoolBossWrapper script?
    Post edited by henkesky1 on
  • You'd have to check if the game object was disabled and destroy it if not.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • edited February 23
    @gamingislove am actually using the official plugin you uploaded
    Post edited by henkesky1 on
  • @gamingislove please also note that this only happens with combatants game object. Other game object seems to work fine
  • Will look into this soon.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • @gamingislove please let me know when you do it
  • @gamingislove please will you be able to give a time frame when this can be fixed?
  • I should be able to look into it sometime next week.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • @gamingislove hello, how is work? I know your very busy. Just to remind you of our last discussion concerning issues with poolboss integration
  • I've updated the plugin, it'll now destroy game objects if they aren't disabled after despawning with pool boss.
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.