NodePool keeps object after calling get method

Hello again :slight_smile:

I’m using the cc.NodePool class for pooling some prefab which looks very nice to use. My question is, once you call the get method, is it normal that the object is still in the pool? is there a way to remove it from the pool while it is used? My code looks like:
getPrefab: function () { ____let prefab = this.pool.get(); ____if(prefab == null) { ________prefab = cc.instantiate(this.prefab); ________this._pool.put(prefab); ____} ____return prefab; }
After calling getPrefab I add the returned object into a node using addChild, but the second call of getPrefab crashes my project with the error Uncaught Error: child already added. It can't be added again.

Thanks for your help :slight_smile:

okay, my mistake…doing this._pool.put(prefab); wasn’t a good idea :slight_smile:. I just removed it and now it works