Save reference to gameObject(s)

I need a way to reference a specific gameObject(s) in between sessions.

For purely conceptual understanding. Lets say I’m standing on a stump surrounded by a million squirrels, I select 3 squirrels in game and every time I snap my fingers those 3 specific squirrels jump.

Perfection this is exactly what I wanted, now how I can save a reference to those 3 squirrels out of a million so that when I restart my game, the exact same squirrels jump when I snap?

EDIT: I’d also like to be able to save my reference to the 3 squirrels to a database so when my friend launches his copy of the game and snaps his fingers he gets the same result. (I know the ins and outs of writing/reading to a database I just don’t know what to write)

For simplicity, the answer is to ensure each squirrel has a Unique ID. Maybe this is their index, maybe it’s a hash based on some properties, maybe it’s something else.

You should have some sort of pool to manage so many objects anyway, so it’s just a case of storing which of those you’re interested in.

Another option is to do something like store the position of the selected objects, then when you load them back in, spawn a squirrel at each of those saved points. You could also store some properties which might make these squirrels unique and re-apply them.