So I’m creating an enemy pool for our game. The pool will hold as many copy of our enemy models that we want to support at any given time.
We also have instance objects that will use the pool. The instances will keep track of the transformation and instance related attributes like health for that enemy.
When the enemy instance gets within range it will request a copy of the model from the pool. The model will then moved into place and controlled by the instance. When the instance falls out of range it will release the copy of the model back into the pool. the instance object will stick around incase it comes back within range.
The part that is tripping me up is the fact that the instance doesn’t currently have a renderer. So i have no way of telling when its within range via the OnBecameVisible and OnBecameInvisible callbacks generated by the renderer.
My current solution is to add a renderer to the instance, create a cube on the fly and assign a transparent shader so that it can then trigger the callbacks. I know this isn’t the smartest idea so thats why i i’m coming here.
So, any advice?