Object Pooling: deactivating vs. moving

Preface (skip if you want):
I’m currently working on a 2d infinite runner that spawns “ground piecs” randomly from a list. Currently I Instantiate prefabs on the right side of the viewport and destroy them when they go off the screen to the left. I’m about to start optimizing this by implementing object pooling.

The Actual Question:
Anyway my question is when I want to “delete” the object (move it back into the pool) is it better to use GameObject.SetActive(false) or to disable the components of the object and move it out of view?

It is your choice and depends on how you build the scene and stuff.

If you have a script with some code in update() function, then it is better to disable the whole game object. This is because even when out of focus UPDATE method runs on all objects

If it is simple gameobject without any scripts attached or some simple script without update (pick up objects would have only OnTriggerEnter()), just move it out of screen, that would do.

DONT go around disabling individual components, because you would have to have maintain lot of references.

My personal suggestion is to disable the object itslef, it is simple to do :wink: