So I've started making abilities for my real time combat, and I realize that I should definitely be using object pooling for all these spawned prefabs (particle effects, damage colliders, etc.), but I'm not sure how to do this with Ork's event system.

I know there's an integration with a product called Pool Boss, and I'd be happy to use that, but could someone explain how that might work before I go down that path? Even the most basic example would be very helpful. I assume I'd have to set up all these object pools at the start of battle?

Additionally, if there's another method you'd suggest, I'm happy to try anything. I just need some kind of pooling system I can use for each ability.

Thanks so much in advance!
  • You connect a custom pooling solution via the Unity Wrapper functionality in Game > Game Settings. This'll funnel every game object spawn through it, so you don't really have to give prefab spawning in events (or anything else) a thought.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited August 2021
    That does sound easy, but I'm running into issues.

    I imported pool boss (version 1.2.1), then imported the plugin found here: http://orkframework.com/plugins/pool-boss-wrapper/

    and then followed the steps laid out for adding the plugin.

    And now I'm getting a bunch of errors in every scene that look something like this:

    Pool Boss has not initialized (does so in Awake event and may take additional frames if you configured it that way) and is not ready to be used yet. Check that PoolBoss.IsReady returns true before calling other methods.
    UnityEngine.Debug:LogError(Object)
    DarkTonic.PoolBoss.PoolBoss:Despawn(Transform, Boolean) (at Assets/DarkTonic/PoolBoss/Scripts/PoolBoss.cs:925)
    ORKPoolBossWrapper:Destroy(GameObject) (at Assets/ORK Framework/Scripts/ORKPoolBossWrapper.cs:34)
    System.Reflection.MethodBase:Invoke(Object, Object[])
    ORKFramework.UnityWrapper:DestroyGameObject(GameObject)
    ORKFramework.UnityWrapper:Destroy(GameObject)
    ORKFramework.GUIBox:Unregister()
    ORKFramework.GUIBox:Tick(Single)
    ORKFramework.GUIHandler:Tick(Single)
    ORKFramework.GUIHandler:Tick()
    ORKFramework.ORKCore:FireTick()
    ORKFramework.ORKHandler:Update()


    as well as this:


    Method call failed (ORKPoolBossWrapper): Instantiate
    Exception has been thrown by the target of an invocation.
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <1f0c1ef1ad524c38bbc5536809c46b48>:0

    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <1f0c1ef1ad524c38bbc5536809c46b48>:0

    at ORKFramework.UnityWrapper.InstantiateGameObject (UnityEngine.GameObject prefab, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) [0x00037] in <6a7acab215dc44b19768ddcebb1ebd48>:0
    UnityEngine.Debug:LogWarning(Object)
    ORKFramework.UnityWrapper:InstantiateGameObject(GameObject, Vector3, Quaternion)
    ORKFramework.UnityWrapper:Instantiate(GameObject, Vector3, Quaternion)
    ORKFramework.Combatants.CombatantObject:Spawn(Vector3, Boolean, Single, Boolean, Vector3)
    ORKFramework.CombatantAccessHandler:Spawn(Combatant, Vector3, Boolean, Single, Boolean, Vector3)
    ORKFramework.Combatants.CombatantObject:SpawnAccess(Vector3, Boolean, Single, Boolean, Vector3)
    ORKFramework.Combatants.CombatantObject:LoadPosition(DataObject)
    ORKFramework.Combatant:.ctor(DataObject, Boolean, Group)
    ORKFramework.Group:LoadMembers(DataObject, Boolean)
    ORKFramework.PlayerHandler:LoadGame(DataObject)
    ORKFramework.SaveGameHandler:Loaded(DataObject)
    ORKFramework.Behaviours.<OnSceneLoaded2>d__27:MoveNext()
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    ORKFramework.Behaviours.SceneChanger:OnSceneLoaded()
    ORKFramework.ORKCore:FireSceneLoaded()
    ORKFramework.ORKCore:OnSceneLoaded(Scene, LoadSceneMode)
    UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)



    Each error looks a bit different, and lines up with whatever is being spawned or destroyed at the time.

    Any idea what the issue might be? Are there steps I'm missing here?
    Thanks a ton!
    Post edited by braytendo on
  • Well, I assume you also need to set up pool boss itself correctly.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited August 2021
    I've figured out the issue. Unless I add a Pool Boss component somewhere in a scene and include all the prefabs spawned in Ork for that scene, it will trigger that error. But I have WAY too many prefabs that I don't need to use object pooling for, is a hassle to set up, and ends up breaking stuff and interacting weird with UI that also use prefabs.

    I don't suppose it would be difficult to update this plugin to spawn/destroy normally on any prefabs not included in a pool boss component? Or maybe just adding an option to include which prefabs to run through custom instantiate and custom destroy?

    Cause really, it seems a bit unnecessary to use object pooling for anything other than particle effects and projectiles.
    Post edited by braytendo on
  • I generally assumed that pool boss (or any other pooling solution) would actually check if something is pooled and otherwise just do a normal spawn.

    Shouldn't be too difficult to add in the wrapper, though currently somewhat lacking time to get into that :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hey GIL,
    I know you're probably swamped, but I was wondering if you ever had a chance to look at adding this at all? If not, that's cool, just wanted to check. :D
  • Not yet :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.